Details
-
Task
-
Resolution: Unresolved
-
P2: Important
-
None
-
None
-
None
Description
Closing a top-level QWindow should have consistent behavior regardless of API used or QWindow subclass in use.
Desired behavior includes:
- deleting the platform window
- application last-window-closed logic
Close APIs include:
- QWindow::close()
- QWindowSystemInterface::handleCloseEvent()
- QWidget::close() (QWidgetWindow)
- QtQuick.window.close() (QQuickWindow)
Requirements:
- Run all close logic at the various levels
- Run close logic in the correct order.
- Deduplicate logic as far as possible.
Previous Work
Some work has been done already for 5.6 and QTBUG-43344. This was partially reverted since it caused the regression described in QTBUG-50854.
Implementation
Control Flow
1) All close API, for top-level QWindows, redirect control to QWindow::close() or QWindowSystemInterface::handleCloseEvent(). QWindow::close() calls handleCloseEvent().
2) The QWindow subclass handles the CloseEvent. It runs subclass-specific close logic, and then calls QWindow::event() to pass the event to the QWindow base implementation.
3) QWindow runs common close logic:
- delete the platform window
- application last-window-closed behavior (but this is currently duplicated in QWidgetWindow)
TODO: who hide()s the window?
quit-on-close
Both QWidget and QWindow have quit-on-close logic. The one difference is that the QWidget version checks WA_QuitOnClose (widgets without that flag won't keep the app alive) while the QWindow version checks QGuiApplication::quitOnLastWindowClosed().
Keeping (and running) both code paths make sense, to catch usages of both WA_QuitOnClose and QGuiApplication::quitOnLastWindowClosed(). This is not the current behavior: instead, QWindow will only run quit-on-close logic for windows that it itself hides (and not for windows that QWidget hides).
Pending Changes
https://codereview.qt-project.org/158701 (Unify window close behavior)
Attachments
Issue Links
- relates to
-
QTBUG-46701 Closing a full screen window via Qt APIs leaves the screen black on macOS
- Closed
-
QTBUG-68069 Exiting fullscreen window leaves the application in fullscreen mode on macOS
- Closed
-
QTBUG-59782 Qt.quit() exits immediately without sending a QCloseEvent
- Closed
-
QTBUG-53365 Regression: After upgrading from 5.5.1 to 5.6.0 QCloseEvent::spontaneous doesn't work.
- Reported
-
QTBUG-112763 Misleading documentation for reject() and "Escape Key" in QDialog
- Reported