Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.1.1, 5.7.1
-
None
-
ArchLinux Qt5.1.1
Description
When creating and showing a QMainWindow the native window can be created before the widget is polished. This order can cause problems in certain themes that want to set some properties on the window that may change some parameters of the underlaying native window (e.g. depth of the window) and since Qt5 doesn't support recreate xcb windows it is then impossible to change it later either. An example of the problem caused by this is translucent background.
Looking at the source code, on initialization of a QWidget, a PolishRequest Event is sent using postEvent. Which will cause QWidget::ensurePolished to be called in the main loop after show() since show() is called for a lot of programs before entering the main loop. Also, in QWidget::setVisible(bool), ensurePolished() is called after create(), maybe this is the right place to fix this problem.
In the following program, calling ensurePolished() or delaying show() in main loop with a QTimer can reverse this order. (See the order with gdb...)
#include <QApplication>
int
main(int argc, char **argv)
{
QApplication app(argc, argv);
QMainWindow w;
// w.ensurePolished();
w.show();
app.exec();
}