See also isValid(), start(), and restart(). Calculations of timer elapsed since invalid data are undefined and will likely produce bizarre results. Marks this QElapsedTimer object as invalid.Īn invalid object can be checked with isValid(). The value of timeout can be -1 to indicate that this timer does not expire, in which case this function will always return false. Returns true if this QElapsedTimer has already expired by timeout milliseconds (that is, more than timeout milliseconds have elapsed). bool QElapsedTimer:: hasExpired( qint64 timeout) const See also start(), restart(), hasExpired(), isValid(), and invalidate(). Returns the number of milliseconds since this QElapsedTimer was last started.Ĭalling this function on a QElapsedTimer that is invalid results in undefined behavior. Returns the clock type that this QElapsedTimer implementation uses. QElapsedTimer::ClockType QElapsedTimer:: clockType() A timer becomes valid once it has been started. Member Function Documentation QElapsedTimer:: QElapsedTimer()Ĭonstructs an invalid QElapsedTimer. This clock uses the Windows functions QueryPerformanceCounter and QueryPerformanceFrequency to access the system's performance counter. This clock type is presented separately from MonotonicClock since macOS and iOS are also Unix systems and may support a POSIX monotonic clock with values differing from the Mach absolute time. This clock type is based on the absolute time presented by Mach kernels, such as that found on macOS. This clock type is used on Unix systems which support POSIX monotonic clocks ( _POSIX_MONOTONIC_CLOCK). This is the system's monotonic clock, expressed in milliseconds since an arbitrary point in the past. This is the only non-monotonic clock that QElapsedTimer may use. This clock type is currently only used on Unix systems that do not support monotonic clocks (see below). It's equivalent to the value returned by the C and POSIX time function, with the milliseconds added. The system time clock is purely the real time, expressed in milliseconds since at 0:00 UTC. The performance counter provided by Windows. The Mach kernel's absolute time (macOS and iOS). The system's monotonic clock, usually found in Unix systems. See also QTime, QTimer, and QDeadlineTimer. If comparing to values produced by other APIs, you should check that the clock used is the same as QElapsedTimer (see QElapsedTimer::clockType()). QElapsedTimer will always use the same clock, so it's safe to compare with the value coming from another process in the same machine. It is, however, possible to exchange the value with other processes running on the same machine, provided that they also use the same reference clock. These values should never be exchanged across the network or saved to disk, since there's no telling whether the computer node receiving the data is the same as the one originating it or if it has rebooted since. This is especially true if the time since the reference is extracted from the QElapsedTimer object ( QElapsedTimer::msecsSinceReference()) and serialised. On the other hand, this means QElapsedTimer values can only be compared with other values that use the same reference. Also unlike QTime, QElapsedTimer is immune to changes in the timezone settings, such as daylight-saving periods. This has the added benefit that QElapsedTimer is immune to time adjustments, such as the user correcting the time. QElapsedTimer will use the platform's monotonic reference clock in all platforms that support it (see QElapsedTimer::isMonotonic()). It is often more convenient to use QDeadlineTimer in this case, which counts towards a timeout in the future instead of tracking elapsed time.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |