How to find the duration of a loop running.
Solved
QML and Qt Quick
-
Hi, how can i find the duration of my for loop using a timer in qml? So that, i want to stop another parallel process for that duration of time.
I found following examples on timer on internet.
Timer{ id: visibilityCheckTimer running: false repeat: false property var callBack onTriggered: callBack() } function setTimeout(callback, delay) { if(timer.running) { console.log("nested calls to setTimeout are not supported"); return; } visibilityCheckTimer.callBack = callback; timer.interval = delay + 1; timer.running = true; }
Thanks in advance.
-
There is no API for getting elapsed time of a loop. You'd need to use another Timer component to measure the running time.
-
Hi,
What if use
Date().getTime()
to obtain current time inms
, then compare it in nextTimer
loop?Timer { id: timer repeat: true property real prevTime: 0 onTriggered: { var currTime = new Date().getTime() if (prevTime > 0) { // skip first loop console.log("timer loop took", currTime - prevTime + "[ms]") prevTime = currTime } } }