qt翻译---QTime
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                qt翻译---QTime
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.                        
                                
                            
                            
                            原創(chuàng)作品,允許轉(zhuǎn)載,轉(zhuǎn)載時(shí)請(qǐng)務(wù)必以超鏈接形式標(biāo)明文章 原始出處 、作者信息和本聲明。否則將追究法律責(zé)任。http://no001.blog.51cto.com/1142339/277559 QTime Class Reference [QtCore module] QTime類提供時(shí)間函數(shù) #include 注意:所有函數(shù)是可重入的 公共函數(shù): QTime() QTime(int h,int m,int s=0,int ms=0) QTime addMSecs(int ms)const QTime addSecs ( int s ) const int elapsed () const int hour () const bool isNull () const bool isValid () const int minute () const int msec () const int msecsTo ( const QTime & t ) const int restart () int second () const int secsTo ( const QTime & t ) const bool setHMS ( int h, int m, int s, int ms = 0 ) void start () QString toString ( const QString & format ) const QString toString ( Qt::DateFormat format = Qt::TextDate ) const bool operator!= ( const QTime & t ) const bool operator< ( const QTime & t ) const bool operator<= ( const QTime & t ) const bool operator== ( const QTime & t ) const bool operator> ( const QTime & t ) const bool operator>= ( const QTime & t ) const 靜態(tài)公共函數(shù): QTime currentTime () QTime fromString ( const QString & string, Qt::DateFormat format = Qt::TextDate ) QTime fromString ( const QString & string, const QString & format ) bool isValid ( int h, int m, int s, int ms = 0 ) 相關(guān)的非成員: QDataStream & operator<< ( QDataStream & out, const QTime & time ) QDataStream & operator>> ( QDataStream & in, QTime & time ) 詳細(xì)描述: QTime對(duì)象包含一個(gè)時(shí)鐘時(shí)間,小時(shí)數(shù),分鐘,秒,和毫秒從午夜起。他能讀目前的時(shí)間,量出消逝的一段時(shí)間。他提供函數(shù)為了比較時(shí)間,熟練控制一個(gè)時(shí)間,通過毫秒數(shù)。 QTime使用24小時(shí)時(shí)鐘格式。他沒有AM和PM的概念。不像QDateTime。QTime不知道時(shí)區(qū)或者日光節(jié)約時(shí)間(夏令時(shí)間)(DST) 一個(gè)QTime對(duì)象典型的創(chuàng)建,要么通過設(shè)置小時(shí),分鐘,秒,毫秒;或者使用靜態(tài)函數(shù)currentTime(),他創(chuàng)造QTime對(duì)象包含系統(tǒng)當(dāng)?shù)氐臅r(shí)間。注意他的準(zhǔn)確性依賴于基本的操作系統(tǒng)的準(zhǔn)確性。不是所有的系統(tǒng)提供一毫秒的精確性。 hour(), minute(), second(), and msec() 函數(shù)提供對(duì)應(yīng)的時(shí)間。相同的信息被提供在text格式通過函數(shù)toString() QTime提供全套的操作來比較兩個(gè)QTime對(duì)象。一個(gè)時(shí)間是被認(rèn)為更小,如果他比另一個(gè)更早。 addSecs()或者addMSecs()函數(shù)能夠得到一個(gè)被給的秒或者毫秒比一個(gè)被給的時(shí)間晚多少。同樣的,secsTo()或者msecsTo()函數(shù)能夠得到兩個(gè)時(shí)間之間的秒或者毫秒。 QTime也能使用函數(shù)start(),restart(),elapsed()函數(shù)來測(cè)量一段消逝的時(shí)間。 成員函數(shù)文件: QTime::QTime () 構(gòu)建一個(gè)空的時(shí)間。一個(gè)空時(shí)間可以是QTime(0,0,0,0),此時(shí)isNull()返回true,isValid()返回false QTime::QTime ( int h, int m, int s = 0, int ms = 0 ) 注意:h在[0,23],m和s在[0,59],ms在[0,999]; QTime QTime::addMSecs ( int ms ) const 返回一個(gè)QTime對(duì)象,包含一個(gè)時(shí)間ms,表示比這個(gè)對(duì)象晚多少ms。如果ms是負(fù)值,表示早多少ms。 QTime QTime::addSecs ( int s ) const 例子: 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 QTime QTime::currentTime () [static] 返回當(dāng)前時(shí)間 int QTime::elapsed () const 返回已經(jīng)消逝的ms數(shù),自從上一個(gè)時(shí)間start()或者restart()被調(diào)用。 注意:計(jì)數(shù)器變成0,當(dāng)24小時(shí)過去了。 警告:如果系統(tǒng)時(shí)鐘設(shè)置已經(jīng)被改變,自從start()或者restart()被調(diào)用,那么結(jié)果不可預(yù)知。這個(gè)能發(fā)生,當(dāng)夏令時(shí)間開或者關(guān)。 QTime QTime::fromString ( const QString & string, Qt::DateFormat format = Qt::TextDate ) [static] 注意:fromString()使用一個(gè)c的當(dāng)?shù)鼐幋a字符串來轉(zhuǎn)換ms到一個(gè)float值。如果默認(rèn)的當(dāng)?shù)夭皇莄,這可能導(dǎo)致兩個(gè)變化嘗試。這應(yīng)該被認(rèn)為是一個(gè)執(zhí)行詳情。 QTime QTime::fromString ( const QString & string, const QString & format ) [static] 下面的表達(dá)來表示格式: 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". 所有其他的表達(dá)將被認(rèn)為是text格式。 QTime time = QTime::fromString("1mm12car00", "m'mm'hcarss"); // time is 12:01.00 如果格式不對(duì),一個(gè)無效的QTime被返回。 QTime time = QTime::fromString("00:710", "hh:ms"); // invalid QTime time = QTime::fromString("1.30", "m.s"); // time is 00:01:30.000 int QTime::hour () const bool QTime::isNull () const bool QTime::isValid () const QTime::isValid(21, 10, 30); // returns true QTime::isValid(22, 5, 62); // returns false int QTime::minute () const int QTime::msec () const nt QTime::msecsTo ( const QTime & t ) const 返回這個(gè)時(shí)間到t的毫秒數(shù)。 注意:QTime返回一天之內(nèi)的時(shí)間差,所以ms范圍-8640000到8640000 int QTime::restart () 設(shè)置這個(gè)時(shí)間為當(dāng)前時(shí)間。返回毫秒數(shù),已經(jīng)消逝的,自從start()或者restart()被調(diào)用。 int QTime::second () const int QTime::secsTo ( const QTime & t ) const bool QTime::setHMS ( int h, int m, int s, int ms = 0 ) 設(shè)置小時(shí),分鐘,秒,毫秒 void QTime::start () 設(shè)置時(shí)間為目前的時(shí)間。 QTime t; t.start(); some_lengthy_task(); qDebug("Time elapsed: %d ms", t.elapsed()); QString QTime::toString ( const QString & format ) const 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 QString QTime::toString ( Qt::DateFormat format = Qt::TextDate ) const 如果格式是Qt::TextDate,字符串格式是HH:MM:SS. 如果格式是Qt::ISODate,字符串格式與iso8601格式相同,也是HH:MM:SS Constant Value Description Qt::TextDate 0 The default Qt format, which includes the day and month name, the day number in the month, and the year in full. The day and month names will be short, localized names. This is basically equivalent to using the date format string, "ddd MMM d yyyy". SeeQDate::toString() for more information. Qt::ISODate 1 ISO 8601 extended format: either YYYY-MM-DD for dates or YYYY-MM-DDTHH:MM:SS for combined dates and times. Qt::SystemLocaleShortDate ? The short format used by the operating system. Qt::SystemLocaleLongDate ? The long format used by the operating system. Qt::DefaultLocaleShortDate ? The short format specified by the application's locale. Qt::DefaultLocaleLongDate ? The long format used by the application's locale. Qt::SystemLocaleDate 2 This enum value is deprecated. Use Qt::SystemLocaleShortDate instead (or Qt::SystemLocaleLongDate if you want long dates). Qt::LocaleDate ? This enum value is deprecated. Use Qt::DefaultLocaleShortDate instead (or Qt::DefaultLocaleLongDate if you want long dates). Qt::LocalDate SystemLocaleDate This enum value is deprecated. Use Qt::SystemLocaleShortDate instead (or Qt::SystemLocaleLongDate if you want long dates). bool QTime::operator!= ( const QTime & t ) const bool QTime::operator< ( const QTime & t ) const bool QTime::operator<= ( const QTime & t ) const bool QTime::operator== ( const QTime & t ) const bool QTime::operator> ( const QTime & t ) const bool QTime::operator>= ( const QTime & t ) const 相關(guān)的非成員: QDataStream & operator<< ( QDataStream & out, const QTime & time ) QDataStream & operator>> ( QDataStream & in, QTime & time )  
 
                        
                        
                        轉(zhuǎn)載于:https://blog.51cto.com/b217dgy/1011462
總結(jié)
以上是生活随笔為你收集整理的qt翻译---QTime的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: Java描述设计模式(07):适配器模式
- 下一篇: fedora8 使用小记之:终端字体设置
