Details
-
Bug
-
Resolution: Fixed
-
P3: Somewhat important
-
5.9.0 Alpha
-
None
Description
It's connected directly to QCoreApplication::quit() in QQmlApplicationEngine.
This is inconsistent because if you declare a Shortcut:
Shortcut {
sequence: StandardKey.Quit
onActivated: {
console.log("quitting now")
context: Qt.ApplicationShortcut
Qt.quit()
}
}
that's useful on most platforms, but on macOS your application has a Quit menu item independently. And that will send a QCloseEvent. The intention after we fix QTBUG-33235 is that any window should be able to veto the closing by rejecting the close event, in a QML onClosing handler. So the consistent cross-platform way to prompt "are you sure" in QML, to save files or whatever, is to implement Window.onClosing(). (You could do that in the Shortcut.onActivated() handler, but it won't work on macOS.) So if you have done that, and you also create a quit Shortcut for non-mac platforms, it needs to end up exiting in the same way, whether you get there via the Shortcut or via the menu item.
This will be consistent with widget-based applications: on macOS if you create a Quit menu item, it will be functional, and your widget windows can handle the close event and veto the closing. If you don't create the Quit menu item, you will still get one automatically, and it will work the same way as if you had created it.
Attachments
Issue Links
- depends on
-
QTBUG-33235 OSX: QQuickWindow doesn't get a closeEvent on Cmd+Q
- Closed
- relates to
-
QTBUG-63389 Shortcut in Window in QML-file crashes if it closes window
- Closed
-
QTBUG-45262 close.accepted = false ignored when QCoreApplication::quit() is called
- Closed
-
QTBUG-53286 Consistent QWindow close event behavior
- Open
For Gerrit Dashboard: QTBUG-59782 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
190057,1 | WIP Qt.quit calls maybeQuit to allow QML to veto in onClosing | dev | qt/qtdeclarative | Status: NEW | -2 | 0 |
272459,3 | WIP: Qt.quit calls maybeQuit to allow QML to veto in onClosing | 5.15 | qt/qtdeclarative | Status: ABANDONED | -2 | 0 |
277640,13 | Deliver Quit event when calling QCoreApplication::quit() | dev | qt/qtbase | Status: MERGED | +2 | 0 |
277851,1 | Teach QCoreApplication::quit() to involve platform in termination | 5.14 | qt/qtbase | Status: ABANDONED | 0 | 0 |
312898,3 | Plumb application quit through platform plugin | dev | qt/qtbase | Status: MERGED | +2 | 0 |