⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qtime.3qt

📁 linux下GUI编程工具qt的在线连接帮助手册
💻 3QT
字号:
'\" t.TH QTime 3qt "11 October 2001" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2001 Trolltech AS.  All rights reserved.  See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQTime \- Clock time functions.PP\fC#include <qdatetime.h>\fR.PP.SS "Public Members".in +1c.ti -1c.BI "\fBQTime\fR ()".br.ti -1c.BI "\fBQTime\fR ( int h, int m, int s = 0, int ms = 0 )".br.ti -1c.BI "bool \fBisNull\fR () const".br.ti -1c.BI "bool \fBisValid\fR () const".br.ti -1c.BI "int \fBhour\fR () const".br.ti -1c.BI "int \fBminute\fR () const".br.ti -1c.BI "int \fBsecond\fR () const".br.ti -1c.BI "int \fBmsec\fR () const".br.ti -1c.BI "QString \fBtoString\fR ( Qt::DateFormat f = Qt::TextDate ) const".br.ti -1c.BI "QString \fBtoString\fR ( const QString & format ) const".br.ti -1c.BI "bool \fBsetHMS\fR ( int h, int m, int s, int ms = 0 )".br.ti -1c.BI "QTime \fBaddSecs\fR ( int nsecs ) const".br.ti -1c.BI "int \fBsecsTo\fR ( const QTime & t ) const".br.ti -1c.BI "QTime \fBaddMSecs\fR ( int ms ) const".br.ti -1c.BI "int \fBmsecsTo\fR ( const QTime & t ) const".br.ti -1c.BI "bool \fBoperator==\fR ( const QTime & t ) const".br.ti -1c.BI "bool \fBoperator!=\fR ( const QTime & t ) const".br.ti -1c.BI "bool \fBoperator<\fR ( const QTime & t ) const".br.ti -1c.BI "bool \fBoperator<=\fR ( const QTime & t ) const".br.ti -1c.BI "bool \fBoperator>\fR ( const QTime & t ) const".br.ti -1c.BI "bool \fBoperator>=\fR ( const QTime & t ) const".br.ti -1c.BI "void \fBstart\fR ()".br.ti -1c.BI "int \fBrestart\fR ()".br.ti -1c.BI "int \fBelapsed\fR () const".br.in -1c.SS "Static Public Members".in +1c.ti -1c.BI "QTime \fBcurrentTime\fR ()".br.ti -1c.BI "QTime \fBfromString\fR ( const QString & s, Qt::DateFormat f = Qt::TextDate )".br.ti -1c.BI "bool \fBisValid\fR ( int h, int m, int s, int ms = 0 )".br.in -1c.SH RELATED FUNCTION DOCUMENTATION.in +1c.ti -1c.BI "QDataStream & \fBoperator<<\fR ( QDataStream & s, const QTime & t )".br.ti -1c.BI "QDataStream & \fBoperator>>\fR ( QDataStream & s, QTime & t )".br.in -1c.SH DESCRIPTIONThe QTime class provides clock time functions..PPA 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 (milli)seconds..PPQTime operates with 24-hour clock format; it has no concept of AM/PM. It operates in local time; it knows nothing about time zones or daylight savings time..PPA 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 that 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..PPThe 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..PPQTime 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..PPThe 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..PPQTime can be used to measure a span of elapsed time using the start(), restart(), and elapsed() functions..PPSee also QDate, QDateTime and Time and Date..SH MEMBER FUNCTION DOCUMENTATION.SH "QTime::QTime ()"Constructs the time 0 hours, minutes, seconds and milliseconds, i.e. 00:00:00.000 (midnight). This is a valid time..PPSee also isValid()..SH "QTime::QTime ( int h, int m, int s = 0, int ms = 0 )"Constructs a time with hour \fIh\fR, minute \fIm\fR, seconds \fIs\fR and milliseconds \fIms\fR..PP\fIh\fR must be in the range 0..23, \fIm\fR and \fIs\fR must be in the range 0..59, and \fIms\fR must be in the range 0..999..PPSee also isValid()..SH "QTime QTime::addMSecs ( int ms ) const"Returns a QTime object containing a time \fIms\fR milliseconds later than the time of this object (or earlier if \fIms\fR is negative)..PPNote that the time will wrap if it passes midnight. See addSecs() for an example..PPSee also addSecs() and msecsTo()..SH "QTime QTime::addSecs ( int nsecs ) const"Returns a QTime object containing a time \fInsecs\fR seconds later than the time of this object (or earlier if \fInsecs\fR is negative)..PPNote that the time will wrap if it passes midnight..PPExample:.PP.nf.br    QTime n( 14, 0, 0 );                // n == 14:00:00.br    QTime t;.br    t = n.addSecs( 70 );                // t == 14:01:10.br    t = n.addSecs( -70 );               // t == 13:58:50.br    t = n.addSecs( 10*60*60 + 5 );      // t == 00:00:05.br    t = n.addSecs( -15*60*60 );         // t == 23:00:00.br.fi.PPSee also addMSecs(), secsTo() and QDateTime::addSecs()..SH "QTime QTime::currentTime ()\fC [static]\fR"Returns the current time as reported by the system clock..PPNote that the accuracy depends on the accuracy of the underlying operating system; not all systems provide 1-millisecond accuracy..PPExamples:.)l aclock/aclock.cpp, dclock/dclock.cpp, t12/cannon.cpp and tictac/tictac.cpp..SH "int QTime::elapsed () const"Returns the number of milliseconds that have elapsed since the last time start() or restart() was called..PPNote that the counter wraps to zero 24 hours after the last call to start() or restart..PPNote that the accuracy depends on the accuracy of the underlying operating system; not all systems provide 1-millisecond accuracy..PP\fBWarning:\fR If the system's clock setting has been changed since the last time start() or restart() was called, the result is undefined. This can happen when daylight savings time is turned on or off..PPSee also start() and restart()..SH "QTime QTime::fromString ( const QString & s, Qt::DateFormat f = Qt::TextDate )\fC [static]\fR"Returns the representation \fIs\fR as a QTime using the format \fIf\fR, or an invalid time if this is not possible..PPNote that Qt::LocalDate cannot be used here..SH "int QTime::hour () const"Returns the hour part (0..23) of the time..PPExample: tictac/tictac.cpp..SH "bool QTime::isNull () const"Returns TRUE if the time is equal to 00:00:00.000; otherwise returns FALSE. A null time is valid..PPSee also isValid()..SH "bool QTime::isValid () const"Returns TRUE if the time is valid; otherwise returns FALSE. The time 23:30:55.746 is valid, whereas 24:12:30 is invalid..PPSee also isNull()..SH "bool QTime::isValid ( int h, int m, int s, int ms = 0 )\fC [static]\fR"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReturns TRUE if the specified time is valid; otherwise returns FALSE..PPThe time is valid if \fIh\fR is in the range 0..23, \fIm\fR and \fIs\fR are in the range 0..59, and \fIms\fR is in the range 0..999..PPExample:.PP.nf.br    QTime::isValid(21, 10, 30); // returns TRUE.br    QTime::isValid(22, 5,  62); // returns FALSE.br.fi.SH "int QTime::minute () const"Returns the minute part (0..59) of the time..PPExamples:.)l aclock/aclock.cpp and tictac/tictac.cpp..SH "int QTime::msec () const"Returns the millisecond part (0..999) of the time..SH "int QTime::msecsTo ( const QTime & t ) const"Returns the number of milliseconds from this time to \fIt\fR (which is negative if \fIt\fR is earlier than this time)..PPBecause QTime measures time within a day and there are 86400 seconds in a day, the result is between -86400 and 86400s..PPSee also secsTo()..SH "bool QTime::operator!= ( const QTime & t ) const"Returns TRUE if this time is different from \fIt\fR; otherwise returns FALSE..SH "bool QTime::operator< ( const QTime & t ) const"Returns TRUE if this time is earlier than \fIt\fR; otherwise returns FALSE..SH "bool QTime::operator<= ( const QTime & t ) const"Returns TRUE if this time is earlier than or equal to \fIt\fR; otherwise returns FALSE..SH "bool QTime::operator== ( const QTime & t ) const"Returns TRUE if this time is equal to \fIt\fR; otherwise returns FALSE..SH "bool QTime::operator> ( const QTime & t ) const"Returns TRUE if this time is later than \fIt\fR; otherwise returns FALSE..SH "bool QTime::operator>= ( const QTime & t ) const"Returns TRUE if this time is later than or equal to \fIt\fR; otherwise returns FALSE..SH "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..PPThis function is guaranteed to be atomic and is thus very handy for repeated measurements. Call start() to start the first measurement and then restart() for each later measurement..PPNote that the counter wraps to zero 24 hours after the last call to start() or restart()..PP\fBWarning:\fR If the system's clock setting has been changed since the last time start() or restart() was called, the result is undefined. This can happen when daylight savings time is turned on or off..PPSee also start(), elapsed() and currentTime()..SH "int QTime::second () const"Returns the second part (0..59) of the time..PPExample: tictac/tictac.cpp..SH "int QTime::secsTo ( const QTime & t ) const"Returns the number of seconds from this time to \fIt\fR (which is negative if \fIt\fR is earlier than this time)..PPBecause QTime measures time within a day and there are 86400 seconds in a day, the result is between -86400 and 86400..PPSee also addSecs() and QDateTime::secsTo()..PPExample: t12/cannon.cpp..SH "bool QTime::setHMS ( int h, int m, int s, int ms = 0 )"Sets the time to hour \fIh\fR, minute \fIm\fR, seconds \fIs\fR and milliseconds \fIms\fR..PP\fIh\fR must be in the range 0..23, \fIm\fR and \fIs\fR must be in the range 0..59, and \fIms\fR must be in the range 0..999. Returns TRUE if the set time is valid; otherwise returns FALSE..PPSee also isValid()..SH "void QTime::start ()"Sets this time to the current time. This is practical for timing:.PP.nf.br    QTime t;.br    t.start();                     // start clock.br    ... // some lengthy task.br    qDebug( "%d\\n", t.elapsed() ); // prints the number of msecs elapsed.br.fi.PPSee also restart(), elapsed() and currentTime()..SH "QString QTime::toString ( const QString & format ) const"Returns the time as a string. The \fIformat\fR parameter determines the format of the result string..PPThese expressions may be used:.TP\fIh\fR - the hour without a leading zero (0..23 or 1..12 if AM/PM display).TP\fIhh\fR - the hour with a leading zero (00..23 or 01..12 if AM/PM display).TP\fIm\fR - the minute without a leading zero (0..59).TP\fImm\fR - the minute with a leading zero (00..59).TP\fIs\fR - the second whithout a leading zero (0..59).TP\fIss\fR - the second whith a leading zero (00..59).TP\fIz\fR - the milliseconds without leading zeroes (0..999).TP\fIzzz\fR - the milliseconds with leading zeroes (000..999).TP\fIAP\fR - switch to AM/PM display. \fIAP\fR will be replaced by either "AM" or "PM"..TP\fIap\fR - switch to am/pm display. \fIap\fR will be replaced by either "am" or "pm"..PPAll other input characters will be ignored..PPExample format Strings (assuming that the QTime is 14:13:09.042).TP"hh:mm:ss.zzz" will result in "14:13:09.042".TP"h:m:s ap" will result in "2:13:9 pm".PPSee also QDate::toString() and QTime::toString()..SH "QString QTime::toString ( Qt::DateFormat f = Qt::TextDate ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReturns the time as a string. Milliseconds are not included. The \fIf\fR parameter determines the format of the string..PPIf \fIf\fR is Qt::TextDate, the string format is HH:MM:SS; e.g. 1 second before midnight would be "23:59:59"..PPIf \fIf\fR is Qt::ISODate, the string format corresponds to the ISO 8601 specification for representations of dates, which is also HH:MM:SS..PPIf \fIf\fR is Qt::LocalDate, the string format depends on the locale settings of the system..SH RELATED FUNCTION DOCUMENTATION.SH "QDataStream & operator<< ( QDataStream & s, const QTime & t )"Writes time \fIt\fR to the stream \fIs\fR..PPSee also Format of the QDataStream operators..SH "QDataStream & operator>> ( QDataStream & s, QTime & t )"Reads a time from the stream \fIs\fR into \fIt\fR..PPSee also Format of the QDataStream operators..SH "SEE ALSO".BR http://doc.trolltech.com/qtime.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com.  See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf you find a bug in Qt, please report it as described in.BR http://doc.trolltech.com/bughowto.html .Good bug reports help us to help you. Thank you..PThe definitive Qt documentation is provided in HTML format; it islocated at $QTDIR/doc/html and can be read using Qt Assistant or witha web browser. This man page is provided as a convenience for thoseusers who prefer man pages, although this format is not officiallysupported by Trolltech. .PIf you find errors in this manual page, please report them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qtime.3qt) and the Qtversion (3.0.0).

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -