Home · Overviews · Examples 

QTime Class Reference
[com.trolltech.qt.core module]

The QTime class provides clock time functions. More...


Detailed Description

The QTime class provides clock time functions.

A QTime object contains a clock time, i.e. the 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 milliseconds.

QTime uses the 24-hour clock format; it has no concept of AM/PM. Unlike QDateTime, QTime knows nothing about time zones or daylight savings time (DST).

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 creates a QTime object that contains the system's local 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. One 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 seconds or milliseconds between two times can be found using secsTo or msecsTo.

QTime can be used to measure a span of elapsed time using the start, restart, and elapsed functions.

See also QDate and QDateTime.


Copyright © 2008 Trolltech Trademarks
Qt Jambi 4.3.5_01