Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-59782

Qt.quit() exits immediately without sending a QCloseEvent

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3: Somewhat important
    • Resolution: Fixed
    • Affects Version/s: 5.9.0 Alpha
    • Fix Version/s: 6.0
    • Labels:
      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

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            Activity

              People

              Assignee:
              vestbo Tor Arne Vestbø
              Reporter:
              srutledg Shawn Rutledge
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews