~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to doc/html/qtime.html

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2009-11-02 18:30:08 UTC
  • mfrom: (1.2.2 upstream)
  • mto: (15.2.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 88.
  • Revision ID: james.westby@ubuntu.com-20091102183008-b6a4gcs128mvfb3m
Tags: upstream-4.6.0~beta1
ImportĀ upstreamĀ versionĀ 4.6.0~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
<!DOCTYPE html
3
3
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
4
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
 
<!-- /fasttmp/mkdist-qt-4.5.2-1245473805/qt-x11-opensource-src-4.5.2/src/corelib/tools/qdatetime.cpp -->
 
5
<!-- qdatetime.cpp -->
6
6
<head>
7
 
  <title>Qt 4.5: QTime Class Reference</title>
 
7
  <title>Qt 4.6: QTime Class Reference</title>
8
8
  <link href="classic.css" rel="stylesheet" type="text/css" />
9
9
</head>
10
10
<body>
 
11
<a name="//apple_ref/cpp/cl//QTime" />
11
12
<table border="0" cellpadding="0" cellspacing="0" width="100%">
12
13
<tr>
13
 
<td align="left" valign="top" width="32"><a href="http://qtsoftware.com/products/qt"><img src="images/qt-logo.png" align="left" border="0" /></a></td>
14
 
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="namespaces.html"><font color="#004faf">All&nbsp;Namespaces</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="modules.html"><font color="#004faf">Modules</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
15
 
<td align="right" valign="top" width="230"></td></tr></table><h1 class="title">QTime Class Reference<br /><span class="small-subtitle">[<a href="qtcore.html">QtCore</a> module]</span>
 
14
<td align="left" valign="top" width="32"><a href="http://qt.nokia.com/"><img src="images/qt-logo.png" align="left" border="0" /></a></td>
 
15
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">All&nbsp;Functions</font></a>&nbsp;&middot; <a href="overviews.html"><font color="#004faf">Overviews</font></a></td><td class="searchBar" align="right" valign="center"><form action="http://www.google.com/cse" id="cse-search-box"><div><input type="hidden" name="cx" value="000136343326384750312:dhbxnqlakyu" /><input type="hidden" name="ie" value="UTF-8" /><input type="text" name="q" size="31" /><input type="submit" name="sa" value="Search" /></div></form></td>
 
16
</tr></table><h1 class="title">QTime Class Reference<br /><span class="small-subtitle">[<a href="qtcore.html">QtCore</a> module]</span>
16
17
</h1>
17
18
<p>The QTime class provides clock time functions. <a href="#details">More...</a></p>
18
 
<pre> #include &lt;QTime&gt;</pre><p><b>Note:</b> All the functions in this class are <a href="threads.html#reentrant">reentrant</a>.</p>
 
19
<pre> #include &lt;QTime&gt;</pre><p><b>Note:</b> All functions in this class are <a href="threads-reentrancy.html#reentrant">reentrant</a>.</p>
19
20
<ul>
20
21
<li><a href="qtime-members.html">List of all members, including inherited members</a></li>
21
22
<li><a href="qtime-qt3.html">Qt 3 support members</a></li>
22
23
</ul>
 
24
<hr />
23
25
<a name="public-functions"></a>
24
 
<h3>Public Functions</h3>
25
 
<ul>
26
 
<li><div class="fn"></div><b><a href="qtime.html#QTime">QTime</a></b> ()</li>
27
 
<li><div class="fn"></div><b><a href="qtime.html#QTime-2">QTime</a></b> ( int <i>h</i>, int <i>m</i>, int <i>s</i> = 0, int <i>ms</i> = 0 )</li>
28
 
<li><div class="fn"></div>QTime <b><a href="qtime.html#addMSecs">addMSecs</a></b> ( int <i>ms</i> ) const</li>
29
 
<li><div class="fn"></div>QTime <b><a href="qtime.html#addSecs">addSecs</a></b> ( int <i>s</i> ) const</li>
30
 
<li><div class="fn"></div>int <b><a href="qtime.html#elapsed">elapsed</a></b> () const</li>
31
 
<li><div class="fn"></div>int <b><a href="qtime.html#hour">hour</a></b> () const</li>
32
 
<li><div class="fn"></div>bool <b><a href="qtime.html#isNull">isNull</a></b> () const</li>
33
 
<li><div class="fn"></div>bool <b><a href="qtime.html#isValid">isValid</a></b> () const</li>
34
 
<li><div class="fn"></div>int <b><a href="qtime.html#minute">minute</a></b> () const</li>
35
 
<li><div class="fn"></div>int <b><a href="qtime.html#msec">msec</a></b> () const</li>
36
 
<li><div class="fn"></div>int <b><a href="qtime.html#msecsTo">msecsTo</a></b> ( const QTime &amp; <i>t</i> ) const</li>
37
 
<li><div class="fn"></div>int <b><a href="qtime.html#restart">restart</a></b> ()</li>
38
 
<li><div class="fn"></div>int <b><a href="qtime.html#second">second</a></b> () const</li>
39
 
<li><div class="fn"></div>int <b><a href="qtime.html#secsTo">secsTo</a></b> ( const QTime &amp; <i>t</i> ) const</li>
40
 
<li><div class="fn"></div>bool <b><a href="qtime.html#setHMS">setHMS</a></b> ( int <i>h</i>, int <i>m</i>, int <i>s</i>, int <i>ms</i> = 0 )</li>
41
 
<li><div class="fn"></div>void <b><a href="qtime.html#start">start</a></b> ()</li>
42
 
<li><div class="fn"></div>QString <b><a href="qtime.html#toString">toString</a></b> ( const QString &amp; <i>format</i> ) const</li>
43
 
<li><div class="fn"></div>QString <b><a href="qtime.html#toString-2">toString</a></b> ( Qt::DateFormat <i>format</i> = Qt::TextDate ) const</li>
44
 
<li><div class="fn"></div>bool <b><a href="qtime.html#operator-not-eq">operator!=</a></b> ( const QTime &amp; <i>t</i> ) const</li>
45
 
<li><div class="fn"></div>bool <b><a href="qtime.html#operator-lt">operator&lt;</a></b> ( const QTime &amp; <i>t</i> ) const</li>
46
 
<li><div class="fn"></div>bool <b><a href="qtime.html#operator-lt-eq">operator&lt;=</a></b> ( const QTime &amp; <i>t</i> ) const</li>
47
 
<li><div class="fn"></div>bool <b><a href="qtime.html#operator-eq-eq">operator==</a></b> ( const QTime &amp; <i>t</i> ) const</li>
48
 
<li><div class="fn"></div>bool <b><a href="qtime.html#operator-gt">operator&gt;</a></b> ( const QTime &amp; <i>t</i> ) const</li>
49
 
<li><div class="fn"></div>bool <b><a href="qtime.html#operator-gt-eq">operator&gt;=</a></b> ( const QTime &amp; <i>t</i> ) const</li>
50
 
</ul>
 
26
<h2>Public Functions</h2>
 
27
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
 
28
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qtime.html#QTime">QTime</a></b> ()</td></tr>
 
29
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qtime.html#QTime-2">QTime</a></b> ( int <i>h</i>, int <i>m</i>, int <i>s</i> = 0, int <i>ms</i> = 0 )</td></tr>
 
30
<tr><td class="memItemLeft" align="right" valign="top">QTime </td><td class="memItemRight" valign="bottom"><b><a href="qtime.html#addMSecs">addMSecs</a></b> ( int <i>ms</i> ) const</td></tr>
 
31
<tr><td class="memItemLeft" align="right" valign="top">QTime </td><td class="memItemRight" valign="bottom"><b><a href="qtime.html#addSecs">addSecs</a></b> ( int <i>s</i> ) const</td></tr>
 
32
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><b><a href="qtime.html#elapsed">elapsed</a></b> () const</td></tr>
 
33
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><b><a href="qtime.html#hour">hour</a></b> () const</td></tr>
 
34
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qtime.html#isNull">isNull</a></b> () const</td></tr>
 
35
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qtime.html#isValid">isValid</a></b> () const</td></tr>
 
36
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><b><a href="qtime.html#minute">minute</a></b> () const</td></tr>
 
37
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><b><a href="qtime.html#msec">msec</a></b> () const</td></tr>
 
38
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><b><a href="qtime.html#msecsTo">msecsTo</a></b> ( const QTime &amp; <i>t</i> ) const</td></tr>
 
39
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><b><a href="qtime.html#restart">restart</a></b> ()</td></tr>
 
40
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><b><a href="qtime.html#second">second</a></b> () const</td></tr>
 
41
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><b><a href="qtime.html#secsTo">secsTo</a></b> ( const QTime &amp; <i>t</i> ) const</td></tr>
 
42
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qtime.html#setHMS">setHMS</a></b> ( int <i>h</i>, int <i>m</i>, int <i>s</i>, int <i>ms</i> = 0 )</td></tr>
 
43
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qtime.html#start">start</a></b> ()</td></tr>
 
44
<tr><td class="memItemLeft" align="right" valign="top">QString </td><td class="memItemRight" valign="bottom"><b><a href="qtime.html#toString">toString</a></b> ( const QString &amp; <i>format</i> ) const</td></tr>
 
45
<tr><td class="memItemLeft" align="right" valign="top">QString </td><td class="memItemRight" valign="bottom"><b><a href="qtime.html#toString-2">toString</a></b> ( Qt::DateFormat <i>format</i> = Qt::TextDate ) const</td></tr>
 
46
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qtime.html#operator-not-eq">operator!=</a></b> ( const QTime &amp; <i>t</i> ) const</td></tr>
 
47
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qtime.html#operator-lt">operator&lt;</a></b> ( const QTime &amp; <i>t</i> ) const</td></tr>
 
48
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qtime.html#operator-lt-eq">operator&lt;=</a></b> ( const QTime &amp; <i>t</i> ) const</td></tr>
 
49
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qtime.html#operator-eq-eq">operator==</a></b> ( const QTime &amp; <i>t</i> ) const</td></tr>
 
50
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qtime.html#operator-gt">operator&gt;</a></b> ( const QTime &amp; <i>t</i> ) const</td></tr>
 
51
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qtime.html#operator-gt-eq">operator&gt;=</a></b> ( const QTime &amp; <i>t</i> ) const</td></tr>
 
52
</table>
 
53
<hr />
51
54
<a name="static-public-members"></a>
52
 
<h3>Static Public Members</h3>
53
 
<ul>
54
 
<li><div class="fn"></div>QTime <b><a href="qtime.html#currentTime">currentTime</a></b> ()</li>
55
 
<li><div class="fn"></div>QTime <b><a href="qtime.html#fromString">fromString</a></b> ( const QString &amp; <i>string</i>, Qt::DateFormat <i>format</i> = Qt::TextDate )</li>
56
 
<li><div class="fn"></div>QTime <b><a href="qtime.html#fromString-2">fromString</a></b> ( const QString &amp; <i>string</i>, const QString &amp; <i>format</i> )</li>
57
 
<li><div class="fn"></div>bool <b><a href="qtime.html#isValid-2">isValid</a></b> ( int <i>h</i>, int <i>m</i>, int <i>s</i>, int <i>ms</i> = 0 )</li>
58
 
</ul>
 
55
<h2>Static Public Members</h2>
 
56
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
 
57
<tr><td class="memItemLeft" align="right" valign="top">QTime </td><td class="memItemRight" valign="bottom"><b><a href="qtime.html#currentTime">currentTime</a></b> ()</td></tr>
 
58
<tr><td class="memItemLeft" align="right" valign="top">QTime </td><td class="memItemRight" valign="bottom"><b><a href="qtime.html#fromString">fromString</a></b> ( const QString &amp; <i>string</i>, Qt::DateFormat <i>format</i> = Qt::TextDate )</td></tr>
 
59
<tr><td class="memItemLeft" align="right" valign="top">QTime </td><td class="memItemRight" valign="bottom"><b><a href="qtime.html#fromString-2">fromString</a></b> ( const QString &amp; <i>string</i>, const QString &amp; <i>format</i> )</td></tr>
 
60
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qtime.html#isValid-2">isValid</a></b> ( int <i>h</i>, int <i>m</i>, int <i>s</i>, int <i>ms</i> = 0 )</td></tr>
 
61
</table>
 
62
<hr />
59
63
<a name="related-non-members"></a>
60
 
<h3>Related Non-Members</h3>
61
 
<ul>
62
 
<li><div class="fn"></div>QDataStream &amp; <b><a href="qtime.html#operator-lt-lt-97">operator&lt;&lt;</a></b> ( QDataStream &amp; <i>out</i>, const QTime &amp; <i>time</i> )</li>
63
 
<li><div class="fn"></div>QDataStream &amp; <b><a href="qtime.html#operator-gt-gt-58">operator&gt;&gt;</a></b> ( QDataStream &amp; <i>in</i>, QTime &amp; <i>time</i> )</li>
64
 
</ul>
 
64
<h2>Related Non-Members</h2>
 
65
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
 
66
<tr><td class="memItemLeft" align="right" valign="top">QDataStream &amp; </td><td class="memItemRight" valign="bottom"><b><a href="qtime.html#operator-lt-lt-113">operator&lt;&lt;</a></b> ( QDataStream &amp; <i>out</i>, const QTime &amp; <i>time</i> )</td></tr>
 
67
<tr><td class="memItemLeft" align="right" valign="top">QDataStream &amp; </td><td class="memItemRight" valign="bottom"><b><a href="qtime.html#operator-gt-gt-61">operator&gt;&gt;</a></b> ( QDataStream &amp; <i>in</i>, QTime &amp; <i>time</i> )</td></tr>
 
68
</table>
65
69
<a name="details"></a>
66
70
<hr />
67
71
<h2>Detailed Description</h2>
76
80
<p>See also <a href="qdate.html">QDate</a> and <a href="qdatetime.html">QDateTime</a>.</p>
77
81
<hr />
78
82
<h2>Member Function Documentation</h2>
 
83
<a name="//apple_ref/cpp/instm/QTime/QTime" />
79
84
<h3 class="fn"><a name="QTime"></a>QTime::QTime ()</h3>
80
85
<p>Constructs a null time object. A null time can be a <a href="qtime.html">QTime</a>(0, 0, 0, 0) (i.e&#x2e;, midnight) object, except that <a href="qtime.html#isNull">isNull</a>() returns true and <a href="qtime.html#isValid">isValid</a>() returns false.</p>
81
86
<p>See also <a href="qtime.html#isNull">isNull</a>() and <a href="qtime.html#isValid">isValid</a>().</p>
83
88
<p>Constructs a time with hour <i>h</i>, minute <i>m</i>, seconds <i>s</i> and milliseconds <i>ms</i>.</p>
84
89
<p><i>h</i> must be in the range 0 to 23, <i>m</i> and <i>s</i> must be in the range 0 to 59, and <i>ms</i> must be in the range 0 to 999.</p>
85
90
<p>See also <a href="qtime.html#isValid">isValid</a>().</p>
 
91
<a name="//apple_ref/cpp/instm/QTime/addMSecs" />
86
92
<h3 class="fn"><a name="addMSecs"></a>QTime QTime::addMSecs ( int <i>ms</i> ) const</h3>
87
93
<p>Returns a <a href="qtime.html">QTime</a> object containing a time <i>ms</i> milliseconds later than the time of this object (or earlier if <i>ms</i> is negative).</p>
88
94
<p>Note that the time will wrap if it passes midnight. See <a href="qtime.html#addSecs">addSecs</a>() for an example.</p>
89
95
<p>See also <a href="qtime.html#addSecs">addSecs</a>() and <a href="qtime.html#msecsTo">msecsTo</a>().</p>
 
96
<a name="//apple_ref/cpp/instm/QTime/addSecs" />
90
97
<h3 class="fn"><a name="addSecs"></a>QTime QTime::addSecs ( int <i>s</i> ) const</h3>
91
98
<p>Returns a <a href="qtime.html">QTime</a> object containing a time <i>s</i> seconds later than the time of this object (or earlier if <i>s</i> is negative).</p>
92
99
<p>Note that the time will wrap if it passes midnight.</p>
98
105
 t = n.addSecs(10 * 60 * 60 + 5);  <span class="comment">// t == 00:00:05</span>
99
106
 t = n.addSecs(-15 * 60 * 60);     <span class="comment">// t == 23:00:00</span></pre>
100
107
<p>See also <a href="qtime.html#addMSecs">addMSecs</a>(), <a href="qtime.html#secsTo">secsTo</a>(), and <a href="qdatetime.html#addSecs">QDateTime::addSecs</a>().</p>
 
108
<a name="//apple_ref/cpp/clm/QTime/currentTime" />
101
109
<h3 class="fn"><a name="currentTime"></a>QTime QTime::currentTime ()&nbsp;&nbsp;<tt> [static]</tt></h3>
102
110
<p>This is an overloaded function.</p>
103
111
<p>Returns the current time as reported by the system clock.</p>
104
112
<p>Note that the accuracy depends on the accuracy of the underlying operating system; not all systems provide 1-millisecond accuracy.</p>
 
113
<a name="//apple_ref/cpp/instm/QTime/elapsed" />
105
114
<h3 class="fn"><a name="elapsed"></a>int QTime::elapsed () const</h3>
106
115
<p>Returns the number of milliseconds that have elapsed since the last time <a href="qtime.html#start">start</a>() or <a href="qtime.html#restart">restart</a>() was called.</p>
107
116
<p>Note that the counter wraps to zero 24 hours after the last call to <a href="qtime.html#start">start</a>() or restart.</p>
108
117
<p>Note that the accuracy depends on the accuracy of the underlying operating system; not all systems provide 1-millisecond accuracy.</p>
109
118
<p><b>Warning:</b> If the system's clock setting has been changed since the last time <a href="qtime.html#start">start</a>() or <a href="qtime.html#restart">restart</a>() was called, the result is undefined. This can happen when daylight savings time is turned on or off.</p>
110
119
<p>See also <a href="qtime.html#start">start</a>() and <a href="qtime.html#restart">restart</a>().</p>
 
120
<a name="//apple_ref/cpp/clm/QTime/fromString" />
111
121
<h3 class="fn"><a name="fromString"></a>QTime QTime::fromString ( const <a href="qstring.html">QString</a> &amp; <i>string</i>, <a href="qt.html#DateFormat-enum">Qt::DateFormat</a> <i>format</i> = Qt::TextDate )&nbsp;&nbsp;<tt> [static]</tt></h3>
112
122
<p>Returns the time represented in the <i>string</i> as a <a href="qtime.html">QTime</a> using the <i>format</i> given, or an invalid time if this is not possible.</p>
113
123
<p>Note that fromString() uses a &quot;C&quot; locale encoded string to convert milliseconds to a float value. If the default locale is not &quot;C&quot;, this may result in two conversion attempts (if the conversion fails for the default locale). This should be considered an implementation detail.</p>
114
124
<h3 class="fn"><a name="fromString-2"></a>QTime QTime::fromString ( const <a href="qstring.html">QString</a> &amp; <i>string</i>, const <a href="qstring.html">QString</a> &amp; <i>format</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
115
125
<p>Returns the <a href="qtime.html">QTime</a> represented by the <i>string</i>, using the <i>format</i> given, or an invalid time if the string cannot be parsed.</p>
116
126
<p>These expressions may be used for the format:</p>
117
 
<p><table align="center" cellpadding="2" cellspacing="1" border="0">
 
127
<p><table class="generic" align="center" cellpadding="2" cellspacing="1" border="0">
118
128
<thead><tr valign="top" class="qt-style"><th>Expression</th><th>Output</th></tr></thead>
119
129
<tr valign="top" class="odd"><td>h</td><td>the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display)</td></tr>
120
130
<tr valign="top" class="even"><td>hh</td><td>the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display)</td></tr>
137
147
<span class="comment"> // time is 00:01:30.000</span></pre>
138
148
<p><a href="qdatetime.html#toString">QDateTime::toString</a>() <a href="qtime.html#toString">QTime::toString</a>()</p>
139
149
<p>See also <a href="qdatetime.html#fromString">QDateTime::fromString</a>(), <a href="qdate.html#fromString">QDate::fromString</a>(), and <a href="qdate.html#toString">QDate::toString</a>().</p>
 
150
<a name="//apple_ref/cpp/instm/QTime/hour" />
140
151
<h3 class="fn"><a name="hour"></a>int QTime::hour () const</h3>
141
152
<p>Returns the hour part (0 to 23) of the time.</p>
142
153
<p>See also <a href="qtime.html#minute">minute</a>(), <a href="qtime.html#second">second</a>(), and <a href="qtime.html#msec">msec</a>().</p>
 
154
<a name="//apple_ref/cpp/instm/QTime/isNull" />
143
155
<h3 class="fn"><a name="isNull"></a>bool QTime::isNull () const</h3>
144
156
<p>Returns true if the time is null (i.e&#x2e;, the <a href="qtime.html">QTime</a> object was constructed using the default constructor); otherwise returns false. A null time is also an invalid time.</p>
145
157
<p>See also <a href="qtime.html#isValid">isValid</a>().</p>
 
158
<a name="//apple_ref/cpp/instm/QTime/isValid" />
146
159
<h3 class="fn"><a name="isValid"></a>bool QTime::isValid () const</h3>
147
160
<p>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.</p>
148
161
<p>See also <a href="qtime.html#isNull">isNull</a>().</p>
153
166
<p>Example:</p>
154
167
<pre> QTime::isValid(21, 10, 30); <span class="comment">// returns true</span>
155
168
 QTime::isValid(22, 5,  62); <span class="comment">// returns false</span></pre>
 
169
<a name="//apple_ref/cpp/instm/QTime/minute" />
156
170
<h3 class="fn"><a name="minute"></a>int QTime::minute () const</h3>
157
171
<p>Returns the minute part (0 to 59) of the time.</p>
158
172
<p>See also <a href="qtime.html#hour">hour</a>(), <a href="qtime.html#second">second</a>(), and <a href="qtime.html#msec">msec</a>().</p>
 
173
<a name="//apple_ref/cpp/instm/QTime/msec" />
159
174
<h3 class="fn"><a name="msec"></a>int QTime::msec () const</h3>
160
175
<p>Returns the millisecond part (0 to 999) of the time.</p>
161
176
<p>See also <a href="qtime.html#hour">hour</a>(), <a href="qtime.html#minute">minute</a>(), and <a href="qtime.html#second">second</a>().</p>
 
177
<a name="//apple_ref/cpp/instm/QTime/msecsTo" />
162
178
<h3 class="fn"><a name="msecsTo"></a>int QTime::msecsTo ( const QTime &amp; <i>t</i> ) const</h3>
163
179
<p>Returns the number of milliseconds from this time to <i>t</i>. If <i>t</i> is earlier than this time, the number of milliseconds returned is negative.</p>
164
180
<p>Because <a href="qtime.html">QTime</a> measures time within a day and there are 86400 seconds in a day, the result is always between -86400000 and 86400000 ms.</p>
165
181
<p>See also <a href="qtime.html#secsTo">secsTo</a>() and <a href="qtime.html#addMSecs">addMSecs</a>().</p>
 
182
<a name="//apple_ref/cpp/instm/QTime/restart" />
166
183
<h3 class="fn"><a name="restart"></a>int QTime::restart ()</h3>
167
184
<p>Sets this time to the current time and returns the number of milliseconds that have elapsed since the last time <a href="qtime.html#start">start</a>() or restart() was called.</p>
168
185
<p>This function is guaranteed to be atomic and is thus very handy for repeated measurements. Call <a href="qtime.html#start">start</a>() to start the first measurement, and restart() for each later measurement.</p>
169
186
<p>Note that the counter wraps to zero 24 hours after the last call to <a href="qtime.html#start">start</a>() or restart().</p>
170
187
<p><b>Warning:</b> If the system's clock setting has been changed since the last time <a href="qtime.html#start">start</a>() or restart() was called, the result is undefined. This can happen when daylight savings time is turned on or off.</p>
171
188
<p>See also <a href="qtime.html#start">start</a>(), <a href="qtime.html#elapsed">elapsed</a>(), and <a href="qtime.html#currentTime">currentTime</a>().</p>
 
189
<a name="//apple_ref/cpp/instm/QTime/second" />
172
190
<h3 class="fn"><a name="second"></a>int QTime::second () const</h3>
173
191
<p>Returns the second part (0 to 59) of the time.</p>
174
192
<p>See also <a href="qtime.html#hour">hour</a>(), <a href="qtime.html#minute">minute</a>(), and <a href="qtime.html#msec">msec</a>().</p>
 
193
<a name="//apple_ref/cpp/instm/QTime/secsTo" />
175
194
<h3 class="fn"><a name="secsTo"></a>int QTime::secsTo ( const QTime &amp; <i>t</i> ) const</h3>
176
195
<p>Returns the number of seconds from this time to <i>t</i>. If <i>t</i> is earlier than this time, the number of seconds returned is negative.</p>
177
196
<p>Because <a href="qtime.html">QTime</a> measures time within a day and there are 86400 seconds in a day, the result is always between -86400 and 86400.</p>
178
197
<p>secsTo() does not take into account any milliseconds.</p>
179
198
<p>See also <a href="qtime.html#addSecs">addSecs</a>() and <a href="qdatetime.html#secsTo">QDateTime::secsTo</a>().</p>
 
199
<a name="//apple_ref/cpp/instm/QTime/setHMS" />
180
200
<h3 class="fn"><a name="setHMS"></a>bool QTime::setHMS ( int <i>h</i>, int <i>m</i>, int <i>s</i>, int <i>ms</i> = 0 )</h3>
181
201
<p>Sets the time to hour <i>h</i>, minute <i>m</i>, seconds <i>s</i> and milliseconds <i>ms</i>.</p>
182
202
<p><i>h</i> must be in the range 0 to 23, <i>m</i> and <i>s</i> must be in the range 0 to 59, and <i>ms</i> must be in the range 0 to 999. Returns true if the set time is valid; otherwise returns false.</p>
183
203
<p>See also <a href="qtime.html#isValid">isValid</a>().</p>
 
204
<a name="//apple_ref/cpp/instm/QTime/start" />
184
205
<h3 class="fn"><a name="start"></a>void QTime::start ()</h3>
185
206
<p>Sets this time to the current time. This is practical for timing:</p>
186
207
<pre> QTime t;
188
209
 some_lengthy_task();
189
210
 qDebug(&quot;Time elapsed: %d ms&quot;, t.elapsed());</pre>
190
211
<p>See also <a href="qtime.html#restart">restart</a>(), <a href="qtime.html#elapsed">elapsed</a>(), and <a href="qtime.html#currentTime">currentTime</a>().</p>
 
212
<a name="//apple_ref/cpp/instm/QTime/toString" />
191
213
<h3 class="fn"><a name="toString"></a><a href="qstring.html">QString</a> QTime::toString ( const <a href="qstring.html">QString</a> &amp; <i>format</i> ) const</h3>
192
214
<p>Returns the time as a string. The <i>format</i> parameter determines the format of the result string.</p>
193
215
<p>These expressions may be used:</p>
194
 
<p><table align="center" cellpadding="2" cellspacing="1" border="0">
 
216
<p><table class="generic" align="center" cellpadding="2" cellspacing="1" border="0">
195
217
<thead><tr valign="top" class="qt-style"><th>Expression</th><th>Output</th></tr></thead>
196
218
<tr valign="top" class="odd"><td>h</td><td>the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display)</td></tr>
197
219
<tr valign="top" class="even"><td>hh</td><td>the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display)</td></tr>
208
230
</table></p>
209
231
<p>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. Two consecutive singlequotes (&quot;''&quot;) are replaced by a singlequote in the output.</p>
210
232
<p>Example format strings (assuming that the <a href="qtime.html">QTime</a> is 14:13:09.042)</p>
211
 
<p><table align="center" cellpadding="2" cellspacing="1" border="0">
 
233
<p><table class="generic" align="center" cellpadding="2" cellspacing="1" border="0">
212
234
<thead><tr valign="top" class="qt-style"><th>Format</th><th>Result</th></tr></thead>
213
235
<tr valign="top" class="odd"><td>hh:mm:ss.zzz</td><td>14:13:09.042</td></tr>
214
236
<tr valign="top" class="even"><td>h:m:s ap</td><td>2:13:9 pm</td></tr>
224
246
<p>If the <i>format</i> is <a href="qt.html#DateFormat-enum">Qt::SystemLocaleShortDate</a> or <a href="qt.html#DateFormat-enum">Qt::SystemLocaleLongDate</a>, the string format depends on the locale settings of the system. Identical to calling <a href="qlocale.html#system">QLocale::system</a>().toString(time, <a href="qlocale.html#FormatType-enum">QLocale::ShortFormat</a>) or <a href="qlocale.html#system">QLocale::system</a>().toString(time, <a href="qlocale.html#FormatType-enum">QLocale::LongFormat</a>).</p>
225
247
<p>If the <i>format</i> is <a href="qt.html#DateFormat-enum">Qt::DefaultLocaleShortDate</a> or <a href="qt.html#DateFormat-enum">Qt::DefaultLocaleLongDate</a>, the string format depends on the default application locale. This is the locale set with <a href="qlocale.html#setDefault">QLocale::setDefault</a>(), or the system locale if no default locale has been set. Identical to calling QLocale().toString(time, <a href="qlocale.html#FormatType-enum">QLocale::ShortFormat</a>) or QLocale().toString(time, <a href="qlocale.html#FormatType-enum">QLocale::LongFormat</a>).</p>
226
248
<p>If the time is invalid, an empty string will be returned.</p>
 
249
<a name="//apple_ref/cpp/instm/QTime/operator!=" />
227
250
<h3 class="fn"><a name="operator-not-eq"></a>bool QTime::operator!= ( const QTime &amp; <i>t</i> ) const</h3>
228
251
<p>Returns true if this time is different from <i>t</i>; otherwise returns false.</p>
 
252
<a name="//apple_ref/cpp/instm/QTime/operator<" />
229
253
<h3 class="fn"><a name="operator-lt"></a>bool QTime::operator&lt; ( const QTime &amp; <i>t</i> ) const</h3>
230
254
<p>Returns true if this time is earlier than <i>t</i>; otherwise returns false.</p>
 
255
<a name="//apple_ref/cpp/instm/QTime/operator<=" />
231
256
<h3 class="fn"><a name="operator-lt-eq"></a>bool QTime::operator&lt;= ( const QTime &amp; <i>t</i> ) const</h3>
232
257
<p>Returns true if this time is earlier than or equal to <i>t</i>; otherwise returns false.</p>
 
258
<a name="//apple_ref/cpp/instm/QTime/operator==" />
233
259
<h3 class="fn"><a name="operator-eq-eq"></a>bool QTime::operator== ( const QTime &amp; <i>t</i> ) const</h3>
234
260
<p>Returns true if this time is equal to <i>t</i>; otherwise returns false.</p>
 
261
<a name="//apple_ref/cpp/instm/QTime/operator>" />
235
262
<h3 class="fn"><a name="operator-gt"></a>bool QTime::operator&gt; ( const QTime &amp; <i>t</i> ) const</h3>
236
263
<p>Returns true if this time is later than <i>t</i>; otherwise returns false.</p>
 
264
<a name="//apple_ref/cpp/instm/QTime/operator>=" />
237
265
<h3 class="fn"><a name="operator-gt-eq"></a>bool QTime::operator&gt;= ( const QTime &amp; <i>t</i> ) const</h3>
238
266
<p>Returns true if this time is later than or equal to <i>t</i>; otherwise returns false.</p>
239
267
<hr />
240
268
<h2>Related Non-Members</h2>
241
 
<h3 class="fn"><a name="operator-lt-lt-97"></a><a href="qdatastream.html">QDataStream</a> &amp; operator&lt;&lt; ( <a href="qdatastream.html">QDataStream</a> &amp; <i>out</i>, const QTime &amp; <i>time</i> )</h3>
 
269
<h3 class="fn"><a name="operator-lt-lt-113"></a><a href="qdatastream.html">QDataStream</a> &amp; operator&lt;&lt; ( <a href="qdatastream.html">QDataStream</a> &amp; <i>out</i>, const QTime &amp; <i>time</i> )</h3>
242
270
<p>Writes <i>time</i> to stream <i>out</i>.</p>
243
271
<p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.</p>
244
 
<h3 class="fn"><a name="operator-gt-gt-58"></a><a href="qdatastream.html">QDataStream</a> &amp; operator&gt;&gt; ( <a href="qdatastream.html">QDataStream</a> &amp; <i>in</i>, QTime &amp; <i>time</i> )</h3>
 
272
<h3 class="fn"><a name="operator-gt-gt-61"></a><a href="qdatastream.html">QDataStream</a> &amp; operator&gt;&gt; ( <a href="qdatastream.html">QDataStream</a> &amp; <i>in</i>, QTime &amp; <i>time</i> )</h3>
245
273
<p>Reads a time from stream <i>in</i> into the given <i>time</i>.</p>
246
274
<p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.</p>
247
275
<p /><address><hr /><div align="center">
248
276
<table width="100%" cellspacing="0" border="0"><tr class="address">
249
 
<td width="30%" align="left">Copyright &copy; 2009 Nokia Corporation and/or its subsidiary(-ies)</td>
250
 
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
251
 
<td width="30%" align="right"><div align="right">Qt 4.5.2</div></td>
252
 
</tr></table></div></address></body>
 
277
<td width="40%" align="left">Copyright &copy; 2009 Nokia Corporation and/or its subsidiary(-ies)</td>
 
278
<td width="20%" align="center"><a href="trademarks.html">Trademarks</a></td>
 
279
<td width="40%" align="right"><div align="right">Qt 4.6.0</div></td>
 
280
<script type="text/javascript" src="http://www.google.com/jsapi"></script><script type="text/javascript">google.load("elements", "1", {packages: "transliteration"});</script><script type="text/javascript" src="http://www.google.com/coop/cse/t13n?form=cse-search-box&t13n_langs=en"></script><script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&lang=en"></script></tr></table></div></address></body>
253
281
</html>