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

need a way to intercept closing of a Window in Qt Quick

    XMLWordPrintable

Details

    • 81b3c4bbb085c9d60dd935e5c74e86988d81dca7

    Description

      A widget application typically overrides QWidget::closeEvent() and can ignore() the event to prevent closing the window. The typical use case is to open a file dialog and prompt the user to save any unsaved work. In Qt Quick, one could override QWindow::event(), but there is no way to do it with a QML Window { }; and if you try to use C++ for that, you will need to instantiate your subclass of window rather than a plain QQuickWindow, making it non-transparent in QML. So we need to add a similar mechanism, so that in QML it's possible to write an onClosing(closeEvent) handler or something like that, and reject/ignore the event.

      Attachments

        1. onclosing.qml
          0.2 kB
          Shawn Rutledge

        Issue Links

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

          Activity

            People

              srutledg Shawn Rutledge
              srutledg Shawn Rutledge
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes