Questions tagged [qelapsedtimer]

The QElapsedTimer class provides a fast way to calculate elapsed times.

The QElapsedTimer class provides a fast way to calculate elapsed times. The QElapsedTimer class is usually used to quickly calculate how much time has elapsed between two events. Its API is similar to that of QTime, so code that was using that can be ported quickly to the new class.

However, unlike QTime, QElapsedTimer tries to use monotonic clocks if possible. This means it's not possible to convert QElapsedTimer objects to a human-readable time.

The typical use-case for the class is to determine how much time was spent in a slow operation. The simplest example of such a case is for debugging purposes. QElapsedTimer will use the platform's monotonic reference clock in all platforms that support it. This has the added benefit that QElapsedTimer is immune to time adjustments, such as the user correcting the time. Also unlike QTime, QElapsedTimer is immune to changes in the timezone settings, such as daylight savings periods.

You should be using this tag if your question is related to the use of QElapsedTimer class or its APIs.

6 questions
7
votes
3 answers

How to stop QElapsedTimer?

QElapsedTimer timer; timer.start(); slowOperation1(); qDebug() << "The slow operation took" << timer.elapsed() << "milliseconds"; http://doc.qt.io/qt-5/qelapsedtimer.html#invalidate After qDebug() I would want to stop this timer.…
Aquarius_Girl
  • 21,790
  • 65
  • 230
  • 411
5
votes
1 answer

QML Timer - How to improve accuracy?

I'm developing a QML metronome. I used a timer with interval 60000/Beats per minute. However it isn't really accurate. How can I improve the accuracy. Should I use a Timer, or is there a better solution?
user1217990
  • 65
  • 1
  • 6
1
vote
2 answers

How to use QElapsedTimer without a QTimer?

When I tried to use QElapsedTimer to clear a text in a label I couldn't find a way of using it without a QTimer. Is there a way of connecting a method so that it will do something when the QElapsedTimer reaches a certain value? To be more specific,…
tad
  • 117
  • 7
0
votes
1 answer

Algorithm for masking time when the signal is above a threshold

I have a realtime signal from a sensor. I need logic to implement a masking time once the signal is above a threshold. As shown below: Here the signal (in blue) crosses a threshold. And I need to mask for any checks for the threshold for a period…
user12800116
0
votes
2 answers

Timer Elapsed with DataGridView?

I am trying to use a Timer. If elapsed, the current time DateTime.Now should show up in my textbox Note like a Reminder. My timer is working, but only if I click on datagridview. If I don't click the datagrid, nothing happens. If I click show up…
Findlis
  • 11
  • 1
-2
votes
2 answers

QT optimize program to execute calculations at particular time intervals (Signal & QTimer elapsed)

Hi I have a file with following format where am trying to calculate the position of aircraft from radar (approaching airport) every 10 msecs. Position_X Position_Y Heading Speed t1 t2 w1 t3 w2 t4 Where w1, w2 = turn rate in this case {t1,…