Discussion:
[Interest] Qml Window: handling close events?
Josh Faust
2013-05-04 01:54:05 UTC
Permalink
There doesn't appear to be any way of handling Window close events in
QtQuick (nor, now that I look at it, in QWindow). Am I missing something
obvious?

Josh
Rutledge Shawn
2013-05-06 10:51:45 UTC
Permalink
There doesn't appear to be any way of handling Window close events in QtQuick (nor, now that I look at it, in QWindow). Am I missing something obvious?
onVisibleChanged or onVisibilityChanged perhaps? But it happens after the window is already closed, so you can do some auto-saving of data for example, but it's a bit late to pop up a FileDialog to prompt the user where to save (the FileDialog would have no visible parent window). Otherwise you could override QWindow::event() and handle the close event, but it's inconvenient to write the C++ and then change your QML to use the custom subclass, for such an expected feature. I guess we will need to think of an easier way.

https://bugreports.qt-project.org/browse/QTBUG-31019
Josh Faust
2013-05-06 16:27:46 UTC
Permalink
Post by Rutledge Shawn
onVisibleChanged or onVisibilityChanged perhaps? But it happens after the
window is already closed, so you can do some auto-saving of data for
example, but it's a bit late to pop up a FileDialog to prompt the user
where to save (the FileDialog would have no visible parent window).
Otherwise you could override QWindow::event() and handle the close event,
but it's inconvenient to write the C++ and then change your QML to use the
custom subclass, for such an expected feature. I guess we will need to
think of an easier way.
https://bugreports.qt-project.org/browse/QTBUG-31019
Ah, yes, I should have been more explicit in what I meant by "handling". I
meant ignoring -- though I also missed the obvious onVisibleChanged.

Thanks!

Josh

Loading...