How to avoid QWidget show the default background before paintEvent be called
-
Envirment
Win10 + Qt15.4.2 + QWidget Application
Problem
I Create a empty QWidget Application,and put some child widget on it, the rewrite it's paintEvent to fill window to blue.
But when run the program,I found:int main(int argc, char* argv[]){ QApplication a(argc, argv); MyWidget w; w.show(); //After this, w.paintEvent is not called, the widget is shown using default style,such as a white background,but the child widget isn't shown. a.exec(); //After this, w.paintEvent is called, the background is be painted to blue. and child widget is shown. }
That is when start, white background without child widget is shown first, soon, it changed to blue background with all child widget. A serious flash。
Question
How can we avoid this flash? Is it possible to show the widget with all child is shown and paintEvent had been called?
-
And I found the official example of Qt: Style Example is the same。
Example
After show() and before exex():
After exec():
@wgong You can't. Show sends an event to the window manager and it is showing the decoration. It's just a debugging issue.
-
Envirment
Win10 + Qt15.4.2 + QWidget Application
Problem
I Create a empty QWidget Application,and put some child widget on it, the rewrite it's paintEvent to fill window to blue.
But when run the program,I found:int main(int argc, char* argv[]){ QApplication a(argc, argv); MyWidget w; w.show(); //After this, w.paintEvent is not called, the widget is shown using default style,such as a white background,but the child widget isn't shown. a.exec(); //After this, w.paintEvent is called, the background is be painted to blue. and child widget is shown. }
That is when start, white background without child widget is shown first, soon, it changed to blue background with all child widget. A serious flash。
Question
How can we avoid this flash? Is it possible to show the widget with all child is shown and paintEvent had been called?
-
@wgong Qt15.4.2 does not exist. Is it Qt5.14.2? If yes, upgrade your Qt to at least 5.15.2 first. Is your screen a touch screen?
-
@wgong You can't. Show sends an event to the window manager and it is showing the decoration. It's just a debugging issue.
@Christian-Ehrlicher
Thanks for reply. But it not only a debug issue. I test the release mode, the default background appears first, then final background.obvious flash,same as the debug mode. -
@wgong Qt15.4.2 does not exist. Is it Qt5.14.2? If yes, upgrade your Qt to at least 5.15.2 first. Is your screen a touch screen?