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
For Gerrit Dashboard: QTBUG-57882 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
183287,3 | Simplify "minimized" property handling in xcb plugin | dev | qt/qtbase | Status: ABANDONED | -1 | 0 |
185016,17 | Make QWindow's windowState a QFlags of the WindowState | dev | qt/qtbase | Status: MERGED | -2 | 0 |
188971,1 | Windows QPA: Fix MinGW developer build | dev | qt/qtbase | Status: ABANDONED | -1 | 0 |
189039,2 | Windows QPA: Fix MinGW developer build | dev | qt/qtbase | Status: MERGED | +2 | 0 |