Qml application closing issue
Unsolved
QML and Qt Quick
-
I'm building one qml application and I printing console log's every where but if I minimize application and try to close from taskbar how will I capture that close event in console log
Component.onCompleted: { Qt.application.activeChanged.connect(function() { if (!Qt.application.active) { console.log("Application closed from taskbar") } }) }
I tried this above code but this code is printing console log based on visibility if i minimize the application then it's printing which is wrong
-
@praveen_03 said in Qml application closing issue:
if I minimize application and try to close from taskbar how will I capture that close event in console log
Try the
onClosing
signal handler: https://doc.qt.io/Qt-6/qml-qtquick-window.html#closing-signal -
As suggested by @JKSH Simple sample code to handled the same
Window { width: 640 height: 480 visible: true title: qsTr("Hello World") Rectangle{ anchors.fill : parent color: "blue" radius : test.val1 } onClosing : { console.log("Window is closed") } }