Unsolved Insert a character with predefinite settings
-
Hi, everyone:
I would like to insert into a textEdit block a character with some predefinite characteristics, like the family font, the size, the color. I've used the following solution:QFont fnt; QTextCharFormat chF; QTextCursor c= ui->textEdit->textCursor(); QColor color2= QColor(0, 0, 255, 127); ui->textEdit->setTextColor(color2); fnt.setFamily("Comic Sans MS"); fnt.setBold(true); fnt.setItalic(true); fnt.setUnderline(true); fnt.setPointSizeF(12); chF.setFont(fnt); c.insertText("X",chF);
but it doesn't insert the character X with the color that i've chosen.
Can you suggest me another solution, please? -
Hi,
What version of Qt ?
In what platform ?
Can you show what you get ?
Can you provide a minimal compilable example that shows that behavior ? -
Hi
Use
https://doc.qt.io/qt-5/qtextformat.html#setForeground
instead of
ui->textEdit->setTextColor(color2);
then
chF.setForeground(color2);