Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
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
- relates to
-
QTBUG-69711 [REG 5.9->5.10] QWindow doesn't restore previously maximized state after calling showMinimized()
- Reported
-
QTBUG-61595 setWindowState(Qt::WindowFullScreen) and showMinimized() does not work correctly together when QWindowsWindowFunctions::setHasBorderInFullScreen is set
- Closed