Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
6.1.3, 5.15.0 RC2
-
None
-
-
d54bb53247 (qt/qtbase/dev) 4d210319e6 (qt/qtbase/6.2) 4d210319e6 (qt/tqtc-qtbase/6.2) d54bb53247 (qt/tqtc-qtbase/dev)
Description
If empty text is set before setting the placeHolderText then the placeHolderText is not visible:
#include <QApplication> #include <QPlainTextEdit> int main(int argc, char *argv[]) { QApplication a(argc, argv); QPlainTextEdit w; w.setPlainText(""); w.setPlaceholderText("Qt is awesome!!!"); w.show(); return a.exec(); }
If instead if I reverse the order the placeHolderText is visible:
w.setPlaceholderText("Qt is awesome!!!");
w.setPlainText("");
Reviewing the source code I discovered that in setPlaceholderText the variable placeholderVisible is not reevaluated causing this unexpected behavior.
so a possible solution would be to invoke QPlainTextEditPrivate:: _q_textChanged in QPlainTextEdit::setPlaceholderText