Consider this C++ statement (example from docs):
QTimer::singleShot(600000, &app, SLOT(quit()));
How to do the same in .qml JavaScript, something like this QML:
Rectangle {
property int counter: 0
onCounterChanged: {
if (counter > 42) {
// do equivalent of above C++ statement here
}
}
// more code, which actually manipulates counter
}
There's the obvious solution of having separate Timer
, which is then started by this JavaScript code, and I'll accept that as an answer if a one-liner is not possible. Is it?
repeat: false
to get single shot behavior. – Pavel Strakhovrepeat
is false by default, actually. – hydesetTimeout
/setInterval
are out of question since they cannot be used. You can consider this answer as a - rather hackish - approach. By setting parameters in function signature you can reduce the usage to a single line, e.g.delay(/*repeat*/ true, 12000, functionName)
. – BaCaRoZzo