-
Bug
-
Resolution: Duplicate
-
P2: Important
-
None
-
5.3.2
-
None
Window.close() is not documented for QtQuick but for some reason it
- pops up as a suggestion in Qt Creator
- it exists as a valid function that closes a window
The problem is, it does not emit closing() and thus you can not react to X-clicks and close() calls with one onClosing slot.
The next problem is, you cannot re-implement the function. Assume you do the following to fix the problem above:
function close() {
var closeEvent = { accepted: true };
childWindow.closing(closeEvent)
if (closeEvent.accepted)
{
visible = false
}
else
{
console.log("Closing denied")
}
}
and have the following slot
onClosing: {
console.log("Child window is closing …")
close.accepted = false
}
Now, you have a name collision, since the slot parameter close is overwritten by the function name close.
To avoid all this confusion, I think it is necessary to one of the following:
- remove the Window.close() function from QML,
- rename the parameter of the onClosing slot and let Window.close() emit closing
Full example code available here: https://gist.github.com/webmaster128/c0724440033ef153bb96
- duplicates
-
QTBUG-40093 In QML onClosing() signal not fires when Window.close() used
-
- Closed
-