Priority: P2: Important
Affects Version/s: None
Fix Version/s: None
Component/s: GUI: Window management
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:
- QWidget::close() (QWidgetWindow)
- QtQuick.window.close() (QQuickWindow)
- Run all close logic at the various levels
- Run close logic in the correct order.
- Deduplicate logic as far as possible.
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)
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).
https://codereview.qt-project.org/158701 (Unify window close behavior)