QTextEdit text color auto restore. [Solved]
-
Hi everyone,
I use QTextEdit and set text color :
setTextColor(QColor(255,255,255));The color changed ok. But after i cleared the text in QTextEdit, the text color become black (its default color of QTextEdit).
How to change the default text color of QTextEdit? -
have a look at
"setCurrentCharFormat":http://qt-project.org/doc/qt-5.0/qtwidgets/qtextedit.html#setCurrentCharFormatThis wil set wat you want for new text.
As I understand setTextColor only sets the color for the current selection. -
Hi Eddy, I have tried :
@ m_subtitleText = new QTextEdit("");
QTextCharFormat charFormat = m_subtitleText->currentCharFormat();
charFormat.setFontItalic(true);
charFormat.setUnderlineColor(Qt::white);@Same result, text color, underline color restore to default (black) after i clear the text.
The font setting is ok. -
Oh, i found that the familiar funtion SetStyleSheet is ok. I think it's not ok and don't try before :).
@ m_subtitleText->setStyleSheet( tr("QTextEdit{color:%1}").arg(color.name()) );@
-
Does that mean that you solved the problem? If so, please mark the thread as [Solved].)
-
Ok,
i have used both : setTextColor() , and setStyleSheet().