Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.10.1
-
None
-
Windows 10 64bit
Description
Suppose I have an application consisting only of a custom widget which is painted in `paintEvent()` and the painting included drawing of a text. Then starting this application causes visible blinking. For about 100 ms, an empty window is opened and only after this period it is repainted. This may case unpleasant effect in some cases. I suspect that this may be related to some initialization of fonts or something like that because when the pointing does not pain text, this does not happen. Strange thing however is that if I draw any other widget (e.g. `QLabel`) which contains text, this unpleasant effect is gone as if the font were initialized much faster. The code to replicate this:
#include <QApplication> #include <QLabel> #include <QPainter> #include <QVBoxLayout> #include <QWidget> class Widget : public QWidget { Q_OBJECT protected: void paintEvent(QPaintEvent*) { QPainter p(this); p.drawText(20, 20, "XYZ"); } }; int main(int argc, char *argv[]) { QApplication a(argc, argv); auto container = new QWidget(); auto layout = new QVBoxLayout(container); // comment one or the other line //auto label = new QLabel("ABC"); // non-empty label prevents blinking at startup auto label = new QLabel(); layout->addWidget(label); layout->addWidget(new Widget()); container->resize(600, 600); container->show(); return a.exec(); }
Please see the short but noticeable period (I guess 100 ms) after the window is shown but before the text printed. If you uncomment the line with "ABC" label (and comment out the next line), then this unpleasant effect is gone and the window with the texts appears immediately.