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

Cannot show maximized window minimized

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.10.0 Alpha
    • 5.6.2, 5.7.1
    • None
    • Issue reproduced on Windows 10 with Qt 5.6.2, Fedora 25 Linux with Qt 5.7.1 and Qt 4.8.7.

    Description

      The Qt::WindowMaximized flag is cleared when setVisible(true) is called when QWidget::windowState() = Qt::WindowMaximized|Qt::WindowMinimized.

      #include <QApplication>
      #include <QMainWindow>
      #include <QtDebug>
      #include <QTimer>
      
      int main(int argc, char **argv)
      {
          QApplication app(argc, argv);
      
          QMainWindow window;
          window.setWindowState(Qt::WindowMaximized | Qt::WindowMinimized);
          qDebug() << "window state after setting it: " <<  window.windowState();
          window.setVisible(true);
      
          QTimer timer;
          QObject::connect(&timer, &QTimer::timeout, [&window] {
              qDebug() << "window state: " <<  window.windowState();
          });
          timer.setInterval(2000);
          timer.start();
          app.exec();
      }
      

      The program above will print the following output:

      window state after setting it:  QFlags<Qt::WindowState>(WindowMinimized|WindowMaximized)
      window state:  QFlags<Qt::WindowState>(WindowMinimized)
      window state:  QFlags<Qt::WindowState>(WindowMinimized)
      window state:  QFlags<Qt::WindowState>(WindowMinimized)
      window state:  QFlags<Qt::WindowState>(WindowMinimized)
      window state:  QFlags<Qt::WindowState>(WindowMinimized)
      window state:  QFlags<Qt::WindowState>(WindowMinimized)
      window state:  QFlags<Qt::WindowState>(WindowNoState) # After clicking the button in task bar to unminimize
      window state:  QFlags<Qt::WindowState>(WindowMaximized) # After clicking on maximize button in the window decoration
      window state:  QFlags<Qt::WindowState>(WindowMaximized)
      window state:  QFlags<Qt::WindowState>(WindowMaximized)
      window state:  QFlags<Qt::WindowState>(WindowMinimized|WindowMaximized) # After clicking on minimize button in the window decoration
      window state:  QFlags<Qt::WindowState>(WindowMinimized|WindowMaximized)
      window state:  QFlags<Qt::WindowState>(WindowMinimized|WindowMaximized)
      

      This shows that the Qt::WindowMaximized | Qt::WindowMinimized state is perfectly legal, and I can set it, but it doesn't work when I do. Qt simply unsets it for me.

      If you comment in the the 200ms single-shot timer that sets the flag after a while the following output is produced:

      window state after setting it:  QFlags<Qt::WindowState>(WindowMinimized|WindowMaximized)
      window state:  QFlags<Qt::WindowState>(WindowMinimized|WindowMaximized)
      window state:  QFlags<Qt::WindowState>(WindowMinimized|WindowMaximized)
      window state:  QFlags<Qt::WindowState>(WindowNoState) # After clicking the button in task bar to unminimize
      window state:  QFlags<Qt::WindowState>(WindowNoState)
      window state:  QFlags<Qt::WindowState>(WindowNoState)
      

      So not even a dirty workaround works.

      This may be the same issue that was reported in QTBUG-32753, but it was closed with resolution "Incomplete".

      Attachments

        Issue Links

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

          Activity

            People

              ogoffart Olivier Goffart (Woboq GmbH)
              ts Thomas Sondergaard
              Votes:
              2 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes