QTextEdit's text color automatically changed to "grey" (same as placeholder text color)
-
My Qt version is 5.6.2, and OS Ubuntu 16.04
My QTextEdit's text color is white by default. And during the run time, I could change some text content inside. However, when I completely clear the content (say I delete every character inside the text) and re-type some characters, the text color becomes grey, which is same with placeholder's color.
Right now, my solution is connect signal(textChanged()) to a slot(resetTextColor()). In resetTextColor(), I called setTextColor(Qt::white) to reset the text color. But I think this is a pretty silly solution.
Note: I call QTextEdit's slot, setText(QString) to change set my content. -
My Qt version is 5.6.2, and OS Ubuntu 16.04
My QTextEdit's text color is white by default. And during the run time, I could change some text content inside. However, when I completely clear the content (say I delete every character inside the text) and re-type some characters, the text color becomes grey, which is same with placeholder's color.
Right now, my solution is connect signal(textChanged()) to a slot(resetTextColor()). In resetTextColor(), I called setTextColor(Qt::white) to reset the text color. But I think this is a pretty silly solution.
Note: I call QTextEdit's slot, setText(QString) to change set my content. -
Hi @aha_1980 ,
I solved this problem already. I am not sure if this could count as a bug/problem.
Overall, I use stylesheet to change my widget colors. Originally, I set all of my text color to white by applying "QLabel {color: white;}" to my main widget (the root of all widgets). Honestly I don't expect my QTextEdit's (a child of main widget) text color to be changed since it doesn't derive from QLabel. But it does, my text edit color becomes white (default placeholder and cursor are still grey/black). Then it comes to the problem: If I type in some texts, they are in white, but if then I delete them ALL, and type in some texts again, they become grey (same color with placeholder texts).
I solved this by set a stylesheet individually, "QTextEdit { background-color: black; color: white;}" , now my cursor and placeholder now are also white now (great!).
-
Hi,
That does indeed sound fishy. Can you provide a minimal compilable example that shows that behaviour ?
-
Hi,
i run into the same "error".
the easiest way to reproduce is to just create a QTextEdit and change it's color.QTextEdit *edit = new QTextEdit(); edit->setTextColor(QColor(0, 200, 100));
After building the app, just type some text in the Field and then delete all characters. Afterwards the color will be reset to it's default value (white in my case).
Think this is not the desired behaviour.
-
Hi,
i run into the same "error".
the easiest way to reproduce is to just create a QTextEdit and change it's color.QTextEdit *edit = new QTextEdit(); edit->setTextColor(QColor(0, 200, 100));
After building the app, just type some text in the Field and then delete all characters. Afterwards the color will be reset to it's default value (white in my case).
Think this is not the desired behaviour.
@SirNullPointer
Since this seems like unexpected behaviour (I have never had a problem), have you set up this up in a standalone, minimal program, with whatever minimal stylesheet required to show problem? Because otherwise we might wonder about whatever else is going on in your application.... -
I think this is described here: https://bugreports.qt.io/browse/QTBUG-19994
-
yes, it's the problem described in the bugreport.
however, in my case the text color is white afterwards.
On the white background of the textEdit, it is unreadable from that moment on. -
I think it jumps back to a default color (maybe text color).
I also took a look at the code but it's not that easy to understand so I can't provide a fix :(
But maybe @SGaist has some time ;)