Timer still running when main QML is not loaded
QML and Qt Quick
14
Posts
3
Posters
7.5k
Views
1
Watching
-
@ Timer {
id: decrementTimer
interval: 2000 // 2 seconds
repeat: true
running: (mainLoader.source != "home_aspin.qml")onTriggered: { // do your decrement code here Storage.setSetting("setting",hungertext.text) JScript.decrementcode(); } Component.onCompleted: { Storage.initialize() } }@
@ MouseArea {
id: sleep2home
x: 138
y: 407
width: 95
height: 76
onClicked: {
decrementTimer.start();
mainLoader.source = "QML2";}
}@this is inside my main QML, and i dont put timer codes on my QML2
-
But the Timer and the MouseArea are in the same file, correct?
Just trying to make sure I understand the layout fully.
(If the Timer is in a piece of QML which is loaded by a Loader, and that QML is unloaded, then the timer will stop because it doesn't exist anymore. So the timer has to be persistent somewhere.)