QML Timer is blocked?
-
I want to use a repeated QML timer to show a rotating cursor when the user interface thread is blocked ( for example when loading a big QML file ). The timer is not trigger:
@
Item {
property bool doSomething: falseTimer { interval: 500; running: doSomething; repeat: true onTriggered: console.log("triggered") } Loader { id: bigLoader source: doSomething ? "big.qml" : ""
}
}
@When I set doSomething to true the qml is loaded but the timer is not triggered...
-
did you try to give an id to your Timer, then start it width
@idTimer.start()@ when you change the doSometing^^ boolean ? -
Does not work when the Loader is loading the big page. When it's done the timer is triggered (but this also worked in the previous example).
@
Item {
property bool doSomething
onDoSomethingChanged: doSomething ? timer.start() : timer.stop()Loader { source: doSomething ? " big.qml" : "" }
Timer {
id: timer
interval: 1000; running: false; repeat: true
onTriggered: { console.log("triggered") }
}
}
@ -
Hi,
The issue in this case is that Loader loads the QML on the main thread (effectively blocking it), which the Timer is also running on. This has been addressed in QtQuick 2.0 via the asynchronous property added to Loader (which allows animations to run while the loading happens).
Regards,
Michael