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

QMainWindow can fail to update children's geometry in a specific case

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.15.4, 6.2.4
    • Widgets: Main Window
    • None
    • Windows

    Description

      If the initial show() is called before setWindowState(Qt::WindowMaximized) in the constructor of a window sub-classed from QMainWindow, the window's layout and it's children do not get the correct maximized geometry and they appear in a small box in the corner with the following sequence of events

      1. run the attached program. It will open a window in the maximized state.
      2. User action causes QMainWindow::hide() to be called. (Hide button is clicked in this example)
      3. Some time later (2s timer started by the hide in this example) QMainWindow::show() is called and the window is restored but the children do not get the correct geometry.

      If setWindowState(Qt::WindowMaximized) is called before the initial show() in the constructor, this issue does not happen. Included in the example code is a #ifdef to switch the order of these api, enabling and disabling the issue.

      This only happens on windows. I have tested MacOS 12.3 + Qt6.3.1 and KDE Debian 11 + Qt5.15.2 and the children of the QMainWindow always fill the entire maximized window. I have confirmed the issue happens on Windows 10 + Qt5.15.4 and Window 11 + Qt6.2.4

      Attachments

        1. main.cpp
          0.2 kB
        2. show-maximized-bug.pro
          0.1 kB
        3. window-1.cpp
          1 kB
        4. window-1.h
          0.3 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            drwho Jon
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes