Detailed Description
The QTime class provides clock time functions. A QTime object contains a clock time, i.e. a number of hours, minutes, seconds and milliseconds since midnight. It can read the current time from the system clock, and measure a span of elapsed time. It provides functions for comparing times and for manipulating a time by adding a number of (milli)seconds.
QTime operates with 24-hour clock format; it has no concept of AM/PM. It operates with local time; it does not know anything about time zones or daylight savings time.
A QTime object is typically created either by giving the number of hours, minutes, seconds, and milliseconds explicitly, or by using the static function
currentTime(), which makes a QTime object which contains the system's clock time. Note that the accuracy depends on the accuracy of the underlying operating system; not all systems provide 1-millisecond accuracy.
The
hour(),
minute(),
second(), and
msec() functions provide access to the number of hours, minutes, seconds, and milliseconds of the time. The same information is provided in textual format by the
toString() function.
QTime provides a full set of operators to compare two QTime objects. A time is considered smaller than another if it is earlier than the other.
The time a given number of seconds or milliseconds later than a given time can be found using the
addSecs() or
addMSecs() functions. Correspondingly, the number of (milli)seconds between two times can be found using the
secsTo() or
msecsTo() functions.
QTime can be used to measure a span of elapsed time using the
start(),
restart(), and
elapsed() functions.