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.