Provide three menu options to format the text entered in QTextEdit to (1) display the letters in capital letters (2) display the text in red (3) align the text in the center

I did the 2nd and the 3rd part but I can't find the capital letter part

if (name == "Color") {
          textEdit->setTextColor("red");
       }

       if (name == "Capital") {
          textEdit->??????;    
       }

       if (name == "Center") {
          textEdit->setAlignment(Qt::AlignHCenter);
       }

can u give me some guidance please?

Recommended Answers

Something like:

Qstring str = textEdit->toPlainText();
// TODO convert str to uppercase
textEdit->setPlainText(str);

ref: http://harmattan-dev.nokia.com/docs/library/html/qt4/qtextedit.html

Jump to Post

All 3 Replies

I tried this

textEdit->setFont(Qt::AllUppercase);

but it doesn't work. any ideas?

Qstring str = textEdit->toPlainText();
for (auto &s : str)
{
    s.toUpper();
}
textEdit->setPlainText(str);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.