Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-34064

QStyle::polish(QWidget*) is called on MainWindow after a native window is created in QWindow::create()

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.1.1, 5.7.1
    • Widgets: Main Window
    • 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();
      }

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            yyc1992 Yichao Yu
            Votes:
            3 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes