Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
6.6
-
None
-
-
1308f7e0b (dev), 2332a9c67 (6.7)
Description
The following code shows a window, hides it, shows it again, then tries to close it.
#include <QApplication> #include <QTimer> #include <QWindow> #include <QDebug> #include <QMainWindow> #include <QCloseEvent> class Window : public QMainWindow { public: void closeEvent(QCloseEvent *e) { qWarning() << "close event"; hide(); e->ignore(); } }; int main(int argc, char **argv) { QApplication app(argc, argv); auto window = new Window; window->show(); QTimer::singleShot(5000, [window]{ qWarning() << "hide"; window->hide(); QTimer::singleShot(5000, [window]{ qWarning() << "show"; window->windowHandle()->show(); QTimer::singleShot(5000, [window] { qWarning() << "close"; window->close(); }); }); }); return app.exec(); }
Despite calling window->close() the window stays open. The same happens when closing the window via the close button. Expected is that the window is hidden but the application does not terminate.
The problem does not occur when replacing the
window->windowHandle()->show()
with
window->show()
Tested on Qt 6.6 and 6.7 beta, on X11 and Wayland.
The issue is not present in Qt 5.15
The shown code is a condensed version of what happens in various KDE applications when closing to and restoring from system tray. See https://bugs.kde.org/show_bug.cgi?id=478734
Attachments
For Gerrit Dashboard: QTBUG-120316 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
530169,7 | Hide shown widget window on hide | dev | qt/qtbase | Status: ABANDONED | +1 | 0 |
537159,3 | QWidgetWindow: Don't meddle with WA_WState_{Hidden/ExplicitShowHide} | dev | qt/qtbase | Status: MERGED | +2 | 0 |
539505,3 | QWidgetWindow: Don't meddle with WA_WState_{Hidden/ExplicitShowHide} | 6.7 | qt/qtbase | Status: MERGED | +2 | 0 |