#include <qdatetime.h>
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.
Definition at line 115 of file qdatetime.h.
Public Member Functions | |
| QTime () | |
| QTime (int h, int m, int s=0, int ms=0) | |
| bool | isNull () const |
| bool | isValid () const |
| int | hour () const |
| int | minute () const |
| int | second () const |
| int | msec () const |
| QString | toString (Qt::DateFormat f=Qt::TextDate) const |
| QString | toString (const QString &format) const |
| bool | setHMS (int h, int m, int s, int ms=0) |
| QTime | addSecs (int secs) const |
| int | secsTo (const QTime &) const |
| QTime | addMSecs (int ms) const |
| int | msecsTo (const QTime &) const |
| bool | operator== (const QTime &other) const |
| bool | operator!= (const QTime &other) const |
| bool | operator< (const QTime &other) const |
| bool | operator<= (const QTime &other) const |
| bool | operator> (const QTime &other) const |
| bool | operator>= (const QTime &other) const |
| void | start () |
| int | restart () |
| int | elapsed () const |
Static Public Member Functions | |
| static QTime | currentTime () |
| static QTime | fromString (const QString &s, Qt::DateFormat f=Qt::TextDate) |
| static QTime | fromString (const QString &s, const QString &format) |
| static bool | isValid (int h, int m, int s, int ms=0) |
Private Types | |
| enum | TimeFlag |
Private Member Functions | |
| int | ds () const |
Private Attributes | |
| int | mds |
Friends | |
| class | QDateTime |
| class | QDateTimePrivate |
| Q_CORE_EXPORT QDataStream & | operator<< (QDataStream &, const QTime &) |
| Q_CORE_EXPORT QDataStream & | operator>> (QDataStream &, QTime &) |
enum QTime::TimeFlag [private] |
| QTime::QTime | ( | ) | [inline] |
Constructs a null time object. A null time is identical to a QTime(0, 0, 0, 0) (i.e., midnight), except that isNull() and isValid() return false.
Definition at line 118 of file qdatetime.h.
Referenced by fromString().
| QTime::QTime | ( | int | h, | |
| int | m, | |||
| int | s = 0, |
|||
| int | ms = 0 | |||
| ) |
Constructs a time with hour h, minute m, seconds s and milliseconds ms.
h must be in the range 0 to 23, m and s must be in the range 0 to 59, and ms must be in the range 0 to 999.
Definition at line 1239 of file qdatetime.cpp.
References setHMS().
Here is the call graph for this function:

| bool QTime::isNull | ( | ) | const [inline] |
Returns true if the time is null (i.e., the QTime object was constructed using the default constructor); otherwise returns false. A null time is also an invalid time.
Definition at line 121 of file qdatetime.h.
Referenced by QSvgTinyDocument::draw(), QDateTime::isNull(), and RateController::transfer().
| bool QTime::isValid | ( | ) | const |
Returns true if the time is valid; otherwise returns false. For example, the time 23:30:55.746 is valid, but 24:12:30 is invalid.
Definition at line 1262 of file qdatetime.cpp.
References mds, MSECS_PER_DAY, and NullTime.
Referenced by QDateTimeEditPrivate::emitSignals(), fmtDateTime(), QPSQLDriver::formatValue(), QSqlDriver::formatValue(), QIBaseDriver::formatValue(), QDateTime::isValid(), operator<<(), Q3TimeEdit::outOfRange(), QDateTime::QDateTime(), QDateTimeEdit::QDateTimeEdit(), QDateTime::setDate(), setHMS(), QDateTimeEdit::setMaximumTime(), QDateTimeEdit::setMinimumTime(), VariantDelegate::setModelData(), Q3TimeEdit::setRange(), QDateTimeEdit::setTime(), Q3TimeEdit::setTime(), QDateTimeEdit::setTimeRange(), Q3TimeEdit::time(), QTest::toString(), and toString().
01263 { 01264 return mds > NullTime && mds < MSECS_PER_DAY; 01265 }
| int QTime::hour | ( | ) | const |
Returns the hour part (0 to 23) of the time.
Definition at line 1274 of file qdatetime.cpp.
References ds(), and MSECS_PER_HOUR.
Referenced by QAbstractFormBuilder::createProperty(), Q3DateTimeEditor::eventFilter(), QODBCResult::exec(), QIBaseDriver::formatValue(), fromString(), localToUtc(), operator<<(), ShapedClock::paintEvent(), WorldTimeClock::paintEvent(), AnalogClock::paintEvent(), QDateTimeParser::parse(), QDateTimeParser::setDigit(), Q3TimeEdit::setTime(), QDateTimeEdit::stepBy(), Q3TimeEdit::stepDown(), Q3TimeEdit::stepUp(), QLocale::toString(), and toString().
01275 { 01276 return ds() / MSECS_PER_HOUR; 01277 }
Here is the call graph for this function:

| int QTime::minute | ( | ) | const |
Returns the minute part (0 to 59) of the time.
Definition at line 1285 of file qdatetime.cpp.
References ds(), MSECS_PER_HOUR, and MSECS_PER_MIN.
Referenced by QAbstractFormBuilder::createProperty(), Q3DateTimeEditor::eventFilter(), QODBCResult::exec(), QIBaseDriver::formatValue(), fromString(), localToUtc(), operator<<(), ShapedClock::paintEvent(), WorldTimeClock::paintEvent(), AnalogClock::paintEvent(), QDateTimeParser::parse(), QDateTimeParser::setDigit(), Q3TimeEdit::setTime(), QDateTimeEdit::stepBy(), Q3TimeEdit::stepDown(), Q3TimeEdit::stepUp(), QLocale::toString(), and toString().
01286 { 01287 return (ds() % MSECS_PER_HOUR) / MSECS_PER_MIN; 01288 }
Here is the call graph for this function:

| int QTime::second | ( | ) | const |
Returns the second part (0 to 59) of the time.
Definition at line 1296 of file qdatetime.cpp.
References ds(), and SECS_PER_MIN.
Referenced by QAbstractFormBuilder::createProperty(), Q3DateTimeEditor::eventFilter(), QODBCResult::exec(), QIBaseDriver::formatValue(), fromString(), localToUtc(), now(), operator<<(), ShapedClock::paintEvent(), WorldTimeClock::paintEvent(), AnalogClock::paintEvent(), QDateTimeParser::parse(), QDateTimeParser::setDigit(), Q3TimeEdit::setTime(), DigitalClock::showTime(), Q3TimeEdit::stepDown(), Q3TimeEdit::stepUp(), QLocale::toString(), and toString().
01297 { 01298 return (ds() / 1000)%SECS_PER_MIN; 01299 }
Here is the call graph for this function:

| int QTime::msec | ( | ) | const |
Returns the millisecond part (0 to 999) of the time.
Definition at line 1307 of file qdatetime.cpp.
References ds().
Referenced by Q3DateTimeEditor::eventFilter(), QODBCResult::exec(), QPSQLDriver::formatValue(), QIBaseDriver::formatValue(), fromString(), localToUtc(), now(), operator-(), operator<<(), QDateTimeParser::parse(), QDateTimeParser::setDigit(), QLocale::toString(), CompositionRenderer::updateCirclePos(), and utcToLocal().
01308 { 01309 return ds() % 1000; 01310 }
Here is the call graph for this function:

| QString QTime::toString | ( | Qt::DateFormat | f = Qt::TextDate |
) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Returns the time as a string. Milliseconds are not included. The f parameter determines the format of the string.
If f is Qt::TextDate, the string format is HH:MM:SS; e.g. 1 second before midnight would be "23:59:59".
If f is Qt::ISODate, the string format corresponds to the ISO 8601 extended specification for representations of dates, which is also HH:MM:SS.
If f is Qt::LocalDate or Qt::SystemLocaleDate, the string format depends on the locale settings of the system. Identical to calling QLocale::system().toString(time, QLocale::ShortFormat). {Qt::LocalDate has been deprecated, please use Qt::SystemLocaleDate instead.}
If f is Qt::LocaleDate, the string format depends on the default application locale. This is the locale set with QLocale::setDefault(), or the system locale if no default locale has been set. Identical to calling QLocale().toString(time, QLocale::ShortFormat);
If f is Qt::LocalDate, the string format depends on the locale settings of the system.
If the datetime is invalid, an empty string will be returned.
Definition at line 1344 of file qdatetime.cpp.
References QString::arg(), QString::fromLatin1(), hour(), Qt::ISODate, isValid(), Qt::LocaleDate, minute(), second(), QLocale::ShortFormat, QLocale::system(), Qt::SystemLocaleDate, Qt::TextDate, and QLocale::toString().
Referenced by Window::createDateTimeEdits(), QPSQLDriver::formatValue(), QSqlDriver::formatValue(), QODBCDriver::formatValue(), operator<<(), Window::setFormatString(), DigitalClock::showTime(), QDateTime::toString(), QTest::toString(), and qdesigner_internal::TimeProperty::toString().
01345 { 01346 if (!isValid()) 01347 return QString(); 01348 01349 switch (f) { 01350 case Qt::SystemLocaleDate: 01351 return QLocale::system().toString(*this, QLocale::ShortFormat); 01352 case Qt::LocaleDate: 01353 return QLocale().toString(*this, QLocale::ShortFormat); 01354 default: 01355 case Qt::ISODate: 01356 case Qt::TextDate: 01357 return QString::fromLatin1("%1:%2:%3") 01358 .arg(hour(), 2, 10, QLatin1Char('0')) 01359 .arg(minute(), 2, 10, QLatin1Char('0')) 01360 .arg(second(), 2, 10, QLatin1Char('0')); 01361 } 01362 }
Here is the call graph for this function:

Returns the time as a string. The format parameter determines the format of the result string.
These expressions may be used:
Expression Output h the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display) hh the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display) H the hour without a leading zero (0 to 23, even with AM/PM display) HH the hour with a leading zero (00 to 23, even with AM/PM display) m the minute without a leading zero (0 to 59) mm the minute with a leading zero (00 to 59) s the second without a leading zero (0 to 59) ss the second with a leading zero (00 to 59) z the milliseconds without leading zeroes (0 to 999) zzz the milliseconds with leading zeroes (000 to 999) AP or A use AM/PM display. AP will be replaced by either "AM" or "PM". ap or a use am/pm display. ap will be replaced by either "am" or "pm".
All other input characters will be ignored. Any sequence of characters that are enclosed in singlequotes will be treated as text and not be used as an expression.
Example format strings (assuming that the QTime is 14:13:09.042)
Format Result hh:mm:ss.zzz 14:13:09.042 h:m:s ap 2:13:9 pm H:m:s a 14:13:9 pm
If the datetime is invalid, an empty string will be returned.
Definition at line 1409 of file qdatetime.cpp.
References fmtDateTime().
01410 { 01411 return fmtDateTime(format, this, 0); 01412 }
Here is the call graph for this function:

| bool QTime::setHMS | ( | int | h, | |
| int | m, | |||
| int | s, | |||
| int | ms = 0 | |||
| ) |
Sets the time to hour h, minute m, seconds s and milliseconds ms.
h must be in the range 0 to 23, m and s must be in the range 0 to 59, and ms must be in the range 0 to 999. Returns true if the set time is valid; otherwise returns false.
Definition at line 1425 of file qdatetime.cpp.
References isValid(), mds, NullTime, SECS_PER_HOUR, and SECS_PER_MIN.
Referenced by Q3DateTimeEditor::eventFilter(), QDateTime::fromString(), operator>>(), and QTime().
01426 { 01427 if (!isValid(h,m,s,ms)) { 01428 mds = NullTime; // make this invalid 01429 return false; 01430 } 01431 mds = (h*SECS_PER_HOUR + m*SECS_PER_MIN + s)*1000 + ms; 01432 return true; 01433 }
Here is the call graph for this function:

| QTime QTime::addSecs | ( | int | nsecs | ) | const |
Returns a QTime object containing a time nsecs seconds later than the time of this object (or earlier if nsecs is negative).
Note that the time will wrap if it passes midnight.
Example:
QTime n(14, 0, 0); // n == 14:00:00 QTime t; t = n.addSecs(70); // t == 14:01:10 t = n.addSecs(-70); // t == 13:58:50 t = n.addSecs(10 * 60 * 60 + 5); // t == 00:00:05 t = n.addSecs(-15 * 60 * 60); // t == 23:00:00
Definition at line 1455 of file qdatetime.cpp.
References addMSecs().
Referenced by WorldTimeClock::paintEvent(), and QDateTime::setTime_t().
01456 { 01457 return addMSecs(nsecs * 1000); 01458 }
Here is the call graph for this function:

| int QTime::secsTo | ( | const QTime & | t | ) | const |
Returns the number of seconds from this time to t. If t is earlier than this time, the number of seconds returned is negative.
Because QTime measures time within a day and there are 86400 seconds in a day, the result is always between -86400 and 86400.
Definition at line 1471 of file qdatetime.cpp.
Referenced by CannonField::newTarget(), and QDateTime::secsTo().
Here is the call graph for this function:

| QTime QTime::addMSecs | ( | int | ms | ) | const |
Returns a QTime object containing a time ms milliseconds later than the time of this object (or earlier if ms is negative).
Note that the time will wrap if it passes midnight. See addSecs() for an example.
Definition at line 1486 of file qdatetime.cpp.
References ds(), MSECS_PER_DAY, and t.
Referenced by addSecs(), operator+(), operator-(), QSvgTinyDocument::setCurrentFrame(), and AnimationSaveWidget::toggleRecord().
01487 { 01488 QTime t; 01489 if (ms < 0) { 01490 // % not well-defined for -ve, but / is. 01491 int negdays = (MSECS_PER_DAY - ms) / MSECS_PER_DAY; 01492 t.mds = (ds() + ms + negdays * MSECS_PER_DAY) % MSECS_PER_DAY; 01493 } else { 01494 t.mds = (ds() + ms) % MSECS_PER_DAY; 01495 } 01496 return t; 01497 }
Here is the call graph for this function:

| int QTime::msecsTo | ( | const QTime & | t | ) | const |
Returns the number of milliseconds from this time to t. If t is earlier than this time, the number of milliseconds returned is negative.
Because QTime measures time within a day and there are 86400 seconds in a day, the result is always between -86400000 and 86400000 ms.
Definition at line 1511 of file qdatetime.cpp.
Referenced by QDateTimeParser::checkIntermediate(), QX11Data::clipboardWaitForEvent(), QDragManager::drag(), elapsed(), Q3ListView::keyPressEvent(), restart(), toTime(), and toTimeStamp().
Here is the call graph for this function:

| bool QTime::operator== | ( | const QTime & | t | ) | const [inline] |
Returns true if this time is equal to t; otherwise returns false.
Definition at line 139 of file qdatetime.h.
References mds.
00139 { return mds == other.mds; }
| bool QTime::operator!= | ( | const QTime & | t | ) | const [inline] |
Returns true if this time is different from t; otherwise returns false.
Definition at line 140 of file qdatetime.h.
References mds.
00140 { return mds != other.mds; }
| bool QTime::operator< | ( | const QTime & | t | ) | const [inline] |
Returns true if this time is earlier than t; otherwise returns false.
Definition at line 141 of file qdatetime.h.
References mds.
00141 { return mds < other.mds; }
| bool QTime::operator<= | ( | const QTime & | t | ) | const [inline] |
Returns true if this time is earlier than or equal to t; otherwise returns false.
Definition at line 142 of file qdatetime.h.
References mds.
00142 { return mds <= other.mds; }
| bool QTime::operator> | ( | const QTime & | t | ) | const [inline] |
Returns true if this time is later than t; otherwise returns false.
Definition at line 143 of file qdatetime.h.
References mds.
00143 { return mds > other.mds; }
| bool QTime::operator>= | ( | const QTime & | t | ) | const [inline] |
Returns true if this time is later than or equal to t; otherwise returns false.
Definition at line 144 of file qdatetime.h.
References mds.
00144 { return mds >= other.mds; }
| QTime QTime::currentTime | ( | ) | [static] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Returns the current time as reported by the system clock.
Note that the accuracy depends on the accuracy of the underlying operating system; not all systems provide 1-millisecond accuracy.
Definition at line 1564 of file qdatetime.cpp.
References mds, MSECS_PER_HOUR, MSECS_PER_MIN, and t.
Referenced by QX11Data::clipboardWaitForEvent(), Window::createDateTimeEdits(), QDateTime::currentDateTime(), QDragManager::drag(), elapsed(), QTreeView::keyboardSearch(), QAbstractItemView::keyboardSearch(), Q3ListView::keyPressEvent(), main(), CannonField::newTarget(), ShapedClock::paintEvent(), WorldTimeClock::paintEvent(), AnalogClock::paintEvent(), restart(), Producer::run(), DigitalClock::showTime(), and start().
01565 { 01566 QTime ct; 01567 01568 #if defined(Q_OS_WIN) 01569 SYSTEMTIME st; 01570 memset(&st, 0, sizeof(SYSTEMTIME)); 01571 GetLocalTime(&st); 01572 ct.mds = MSECS_PER_HOUR * st.wHour + MSECS_PER_MIN * st.wMinute + 1000 * st.wSecond 01573 + st.wMilliseconds; 01574 #elif defined(Q_OS_UNIX) 01575 // posix compliant system 01576 struct timeval tv; 01577 gettimeofday(&tv, 0); 01578 time_t ltime = tv.tv_sec; 01579 tm *t; 01580 01581 #if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) 01582 // use the reentrant version of localtime() where available 01583 tm res; 01584 t = localtime_r(<ime, &res); 01585 #else 01586 t = localtime(<ime); 01587 #endif 01588 01589 ct.mds = MSECS_PER_HOUR * t->tm_hour + MSECS_PER_MIN * t->tm_min + 1000 * t->tm_sec 01590 + tv.tv_usec / 1000; 01591 #else 01592 time_t ltime; // no millisecond resolution 01593 ::time(<ime); 01594 tm *t; 01595 localtime(<ime); 01596 ct.mds = MSECS_PER_HOUR * t->tm_hour + MSECS_PER_MIN * t->tm_min + 1000 * t->tm_sec; 01597 #endif 01598 return ct; 01599 }
| QTime QTime::fromString | ( | const QString & | string, | |
| Qt::DateFormat | format = Qt::TextDate | |||
| ) | [static] |
Returns the time represented in the string as a QTime using the format given, or an invalid time if this is not possible.
Definition at line 1610 of file qdatetime.cpp.
References hour(), Qt::LocalDate, minute(), msec(), NullTime, qMin(), qRound(), QTime(), qWarning(), s, second(), and t.
Referenced by convert(), QPSQLResult::data(), QDateTime::fromString(), qTimeFromString(), and VariantDelegate::setModelData().
01611 { 01612 if (s.isEmpty() || f == Qt::LocalDate) { 01613 qWarning("QTime::fromString: Parameter out of range"); 01614 QTime t; 01615 t.mds = NullTime; 01616 return t; 01617 } 01618 01619 const int hour(s.mid(0, 2).toInt()); 01620 const int minute(s.mid(3, 2).toInt()); 01621 const int second(s.mid(6, 2).toInt()); 01622 01623 const QString msec_s(QLatin1String("0.") + s.mid(9, 4)); 01624 const float msec(msec_s.toFloat()); 01625 return QTime(hour, minute, second, qMin(qRound(msec * 1000.0), 999)); 01626 }
Here is the call graph for this function:

Returns the QTime represented by the string, using the format given, or an invalid time if the string cannot be parsed.
These expressions may be used for the format:
Expression Output h the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display) hh the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display) m the minute without a leading zero (0 to 59) mm the minute with a leading zero (00 to 59) s the second without a leading zero (0 to 59) ss the second with a leading zero (00 to 59) z the milliseconds without leading zeroes (0 to 999) zzz the milliseconds with leading zeroes (000 to 999) AP interpret as an AM/PM time. AP must be either "AM" or "PM". ap Interpret as an AM/PM time. ap must be either "am" or "pm".
All other input characters will be treated as text. Any sequence of characters that are enclosed in single quotes will also be treated as text and not be used as an expression.
QTime time = QTime::fromString("1mm12car00", "m'mm'hcarss"); // time is 12:01.00
If the format is not satisfied an invalid QTime is returned. Expressions that do not expect leading zeroes to be given (h, m, s and z) are greedy. This means that they will use two digits even if this puts them outside the range of accepted values and leaves too few digits for other sections. For example, the following string could have meant 00:07:10, but the m will grab two digits, resulting in an invalid time:
QTime time = QTime::fromString("00:710", "hh:ms"); // invalid
Any field that is not represented in the format will be set to zero. For example:
QTime time = QTime::fromString("1.30", "m.s"); // time is 00:01:30.000
Definition at line 1687 of file qdatetime.cpp.
References QDateTimeParser::fromString(), QDateTimeParser::parseFormat(), and QVariant::Time.
01688 { 01689 QTime time; 01690 #ifndef QT_BOOTSTRAPPED 01691 QDateTimeParser dt(QVariant::Time); 01692 if (dt.parseFormat(format)) 01693 dt.fromString(string, 0, &time); 01694 #else 01695 Q_UNUSED(string); 01696 Q_UNUSED(format); 01697 #endif 01698 return time; 01699 }
Here is the call graph for this function:

| bool QTime::isValid | ( | int | h, | |
| int | m, | |||
| int | s, | |||
| int | ms = 0 | |||
| ) | [static] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Returns true if the specified time is valid; otherwise returns false.
The time is valid if h is in the range 0 to 23, m and s are in the range 0 to 59, and ms is in the range 0 to 999.
Example:
QTime::isValid(21, 10, 30); // returns true QTime::isValid(22, 5, 62); // returns false
Definition at line 1721 of file qdatetime.cpp.
| void QTime::start | ( | ) |
Sets this time to the current time. This is practical for timing:
Definition at line 1740 of file qdatetime.cpp.
References currentTime().
Referenced by QWidgetAnimator::animate(), QSocks5SocketEngine::bind(), QSocks5SocketEngine::close(), QSvgTinyDocument::draw(), PathDeformRenderer::mouseReleaseEvent(), QMoviePrivate::next(), QGraphicsView::paintEvent(), PathDeformRenderer::PathDeformRenderer(), Connection::processReadyRead(), QTest::qWait(), QRollEffect::run(), QAlphaWidget::run(), PathDeformRenderer::setAnimated(), Q3ProgressDialog::setProgress(), AnimationSaveWidget::toggleRecord(), RateController::transfer(), QProcessPrivate::waitForBytesWritten(), QProcess::waitForBytesWritten(), QAbstractSocket::waitForBytesWritten(), QAbstractSocket::waitForConnected(), QAbstractSocket::waitForDisconnected(), QProcess::waitForFinished(), QProcessPrivate::waitForFinished(), QSocks5SocketEngine::waitForRead(), QAbstractSocket::waitForReadyRead(), QProcessPrivate::waitForReadyRead(), QSocks5SocketEngine::waitForWrite(), and QSocks5SocketEngine::write().
01741 { 01742 *this = currentTime(); 01743 }
Here is the call graph for this function:

| int QTime::restart | ( | ) |
Sets this time to the current time and returns the number of milliseconds that have elapsed since the last time start() or restart() was called.
This function is guaranteed to be atomic and is thus very handy for repeated measurements. Call start() to start the first measurement, and restart() for each later measurement.
Note that the counter wraps to zero 24 hours after the last call to start() or restart().
Definition at line 1765 of file qdatetime.cpp.
References currentTime(), msecsTo(), n, and t.
Referenced by QWidgetAnimator::animationStep(), DisplayWidget::paintEvent(), Connection::processData(), QSvgTinyDocument::restartAnimation(), and PathDeformRenderer::timerEvent().
01766 { 01767 QTime t = currentTime(); 01768 int n = msecsTo(t); 01769 if (n < 0) // passed midnight 01770 n += 86400*1000; 01771 *this = t; 01772 return n; 01773 }
Here is the call graph for this function:

| int QTime::elapsed | ( | ) | const |
Returns the number of milliseconds that have elapsed since the last time start() or restart() was called.
Note that the counter wraps to zero 24 hours after the last call to start() or restart.
Note that the accuracy depends on the accuracy of the underlying operating system; not all systems provide 1-millisecond accuracy.
Definition at line 1793 of file qdatetime.cpp.
References currentTime(), msecsTo(), and n.
Referenced by QSocks5SocketEngine::bind(), QSocks5SocketEngine::close(), QSvgTinyDocument::currentElapsed(), QSvgTinyDocument::currentFrame(), QMoviePrivate::next(), DisplayWidget::paintEvent(), QGraphicsView::paintEvent(), QTest::qWait(), QAlphaWidget::render(), QAlphaWidget::run(), QRollEffect::scroll(), Connection::sendPing(), QSvgTinyDocument::setCurrentFrame(), Q3ProgressDialog::setProgress(), AnimationSaveWidget::timerEvent(), AnimationSaveWidget::toggleRecord(), RateController::transfer(), QProcessPrivate::waitForBytesWritten(), QProcess::waitForBytesWritten(), QAbstractSocket::waitForBytesWritten(), QAbstractSocket::waitForConnected(), QAbstractSocket::waitForDisconnected(), QProcess::waitForFinished(), QProcessPrivate::waitForFinished(), QSocks5SocketEngine::waitForRead(), QAbstractSocket::waitForReadyRead(), QProcessPrivate::waitForReadyRead(), QSocks5SocketEngine::waitForWrite(), and QSocks5SocketEngine::write().
01794 { 01795 int n = msecsTo(currentTime()); 01796 if (n < 0) // passed midnight 01797 n += 86400 * 1000; 01798 return n; 01799 }
Here is the call graph for this function:

| int QTime::ds | ( | ) | const [inline, private] |
Definition at line 163 of file qdatetime.h.
Referenced by QDateTimePrivate::addMSecs(), addMSecs(), hour(), minute(), msec(), msecsTo(), second(), and secsTo().
friend class QDateTime [friend] |
Definition at line 166 of file qdatetime.h.
friend class QDateTimePrivate [friend] |
Definition at line 167 of file qdatetime.h.
| QDataStream & operator<< | ( | QDataStream & | out, | |
| const QTime & | time | |||
| ) | [friend] |
Writes time to stream out.
Definition at line 2811 of file qdatetime.cpp.
| QDataStream & operator>> | ( | QDataStream & | in, | |
| QTime & | time | |||
| ) | [friend] |
Reads a time from stream in into the given time.
Definition at line 2824 of file qdatetime.cpp.
int QTime::mds [private] |
Definition at line 164 of file qdatetime.h.
Referenced by QDateTimePrivate::addMSecs(), currentTime(), isValid(), operator!=(), operator<(), operator<=(), operator==(), operator>(), operator>=(), and setHMS().
1.5.1