Sophie

Sophie

distrib > Mageia > 6 > armv5tl > media > core-updates > by-pkgid > 768f7d9f703884aa2562bf0a651086df > files > 823

qtbase5-doc-5.9.4-1.1.mga6.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qdatetime.cpp -->
  <title>QTime Class | Qt Core 5.9</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td >Qt 5.9</td><td ><a href="qtcore-index.html">Qt Core</a></td><td ><a href="qtcore-module.html">C++ Classes</a></td><td >QTime</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.9.4 Reference Documentation</td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#static-public-members">Static Public Members</a></li>
<li class="level1"><a href="#related-non-members">Related Non-Members</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QTime Class</h1>
<!-- $$$QTime-brief -->
<p>The <a href="qtime.html">QTime</a> class provides clock time functions. <a href="#details">More...</a></p>
<!-- @@@QTime -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QTime&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += core</td></tr></table></div><ul>
<li><a href="qtime-members.html">List of all members, including inherited members</a></li>
</ul>
<p><b>Note:</b> All functions in this class are reentrant.</p>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qtime.html#QTime">QTime</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><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>
<tr><td class="memItemLeft rightAlign topAlign"> QTime </td><td class="memItemRight bottomAlign"><b><a href="qtime.html#addMSecs">addMSecs</a></b>(int <i>ms</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QTime </td><td class="memItemRight bottomAlign"><b><a href="qtime.html#addSecs">addSecs</a></b>(int <i>s</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qtime.html#elapsed">elapsed</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qtime.html#hour">hour</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qtime.html#isNull">isNull</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qtime.html#isValid">isValid</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qtime.html#minute">minute</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qtime.html#msec">msec</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qtime.html#msecsSinceStartOfDay">msecsSinceStartOfDay</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qtime.html#msecsTo">msecsTo</a></b>(const QTime &amp;<i>t</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qtime.html#restart">restart</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qtime.html#second">second</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qtime.html#secsTo">secsTo</a></b>(const QTime &amp;<i>t</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><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>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qtime.html#start">start</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qtime.html#toString">toString</a></b>(const QString &amp;<i>format</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qtime.html#toString-1">toString</a></b>(Qt::DateFormat <i>format</i> = Qt::TextDate) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qtime.html#operator-not-eq">operator!=</a></b>(const QTime &amp;<i>t</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qtime.html#operator-lt">operator&lt;</a></b>(const QTime &amp;<i>t</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qtime.html#operator-lt-eq">operator&lt;=</a></b>(const QTime &amp;<i>t</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qtime.html#operator-eq-eq">operator==</a></b>(const QTime &amp;<i>t</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qtime.html#operator-gt">operator&gt;</a></b>(const QTime &amp;<i>t</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qtime.html#operator-gt-eq">operator&gt;=</a></b>(const QTime &amp;<i>t</i>) const</td></tr>
</table></div>
<a name="static-public-members"></a>
<h2 id="static-public-members">Static Public Members</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> QTime </td><td class="memItemRight bottomAlign"><b><a href="qtime.html#currentTime">currentTime</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QTime </td><td class="memItemRight bottomAlign"><b><a href="qtime.html#fromMSecsSinceStartOfDay">fromMSecsSinceStartOfDay</a></b>(int <i>msecs</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QTime </td><td class="memItemRight bottomAlign"><b><a href="qtime.html#fromString">fromString</a></b>(const QString &amp;<i>string</i>, Qt::DateFormat <i>format</i> = Qt::TextDate)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QTime </td><td class="memItemRight bottomAlign"><b><a href="qtime.html#fromString-1">fromString</a></b>(const QString &amp;<i>string</i>, const QString &amp;<i>format</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qtime.html#isValid-1">isValid</a></b>(int <i>h</i>, int <i>m</i>, int <i>s</i>, int <i>ms</i> = 0)</td></tr>
</table></div>
<a name="related-non-members"></a>
<h2 id="related-non-members">Related Non-Members</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> QDataStream &amp;</td><td class="memItemRight bottomAlign"><b><a href="qtime.html#operator-lt-lt">operator&lt;&lt;</a></b>(QDataStream &amp;<i>out</i>, const QTime &amp;<i>time</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QDataStream &amp;</td><td class="memItemRight bottomAlign"><b><a href="qtime.html#operator-gt-gt">operator&gt;&gt;</a></b>(QDataStream &amp;<i>in</i>, QTime &amp;<i>time</i>)</td></tr>
</table></div>
<a name="details"></a>
<!-- $$$QTime-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>The <a href="qtime.html">QTime</a> class provides clock time functions.</p>
<p>A <a href="qtime.html">QTime</a> object contains a clock time, i.e&#x2e; 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.</p>
<p><a href="qtime.html">QTime</a> uses the 24-hour clock format; it has no concept of AM/PM. Unlike <a href="qdatetime.html">QDateTime</a>, <a href="qtime.html">QTime</a> knows nothing about time zones or daylight-saving time (DST).</p>
<p>A <a href="qtime.html">QTime</a> object is typically created either by giving the number of hours, minutes, seconds, and milliseconds explicitly, or by using the static function <a href="qtime.html#currentTime">currentTime</a>(), which creates a <a href="qtime.html">QTime</a> 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.</p>
<p>The <a href="qtime.html#hour">hour</a>(), <a href="qtime.html#minute">minute</a>(), <a href="qtime.html#second">second</a>(), and <a href="qtime.html#msec">msec</a>() 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 <a href="qtime.html#toString">toString</a>() function.</p>
<p><a href="qtime.html">QTime</a> provides a full set of operators to compare two <a href="qtime.html">QTime</a> objects. <a href="qtime.html">QTime</a> A is considered smaller than <a href="qtime.html">QTime</a> B if A is earlier than B.</p>
<p>The <a href="qtime.html#addSecs">addSecs</a>() and <a href="qtime.html#addMSecs">addMSecs</a>() functions provide the time a given number of seconds or milliseconds later than a given time. Correspondingly, the number of seconds or milliseconds between two times can be found using <a href="qtime.html#secsTo">secsTo</a>() or <a href="qtime.html#msecsTo">msecsTo</a>().</p>
<p><a href="qtime.html">QTime</a> can be used to measure a span of elapsed time using the <a href="qtime.html#start">start</a>(), <a href="qtime.html#restart">restart</a>(), and <a href="qtime.html#elapsed">elapsed</a>() functions.</p>
</div>
<p><b>See also </b><a href="qdate.html">QDate</a> and <a href="qdatetime.html">QDateTime</a>.</p>
<!-- @@@QTime -->
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QTime[overload1]$$$QTime -->
<h3 class="fn" id="QTime"><a name="QTime"></a>QTime::<span class="name">QTime</span>()</h3>
<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 <code>true</code> and <a href="qtime.html#isValid">isValid</a>() returns <code>false</code>.</p>
<p><b>See also </b><a href="qtime.html#isNull">isNull</a>() and <a href="qtime.html#isValid">isValid</a>().</p>
<!-- @@@QTime -->
<!-- $$$QTime$$$QTimeintintintint -->
<h3 class="fn" id="QTime-2"><a name="QTime-2"></a>QTime::<span class="name">QTime</span>(<span class="type">int</span> <i>h</i>, <span class="type">int</span> <i>m</i>, <span class="type">int</span> <i>s</i> = 0, <span class="type">int</span> <i>ms</i> = 0)</h3>
<p>Constructs a time with hour <i>h</i>, minute <i>m</i>, seconds <i>s</i> and milliseconds <i>ms</i>.</p>
<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>
<p><b>See also </b><a href="qtime.html#isValid">isValid</a>().</p>
<!-- @@@QTime -->
<!-- $$$addMSecs[overload1]$$$addMSecsint -->
<h3 class="fn" id="addMSecs"><a name="addMSecs"></a><span class="type"><a href="qtime.html#QTime">QTime</a></span> QTime::<span class="name">addMSecs</span>(<span class="type">int</span> <i>ms</i>) const</h3>
<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>
<p>Note that the time will wrap if it passes midnight. See <a href="qtime.html#addSecs">addSecs</a>() for an example.</p>
<p>Returns a null time if this time is invalid.</p>
<p><b>See also </b><a href="qtime.html#addSecs">addSecs</a>(), <a href="qtime.html#msecsTo">msecsTo</a>(), and <a href="qdatetime.html#addMSecs">QDateTime::addMSecs</a>().</p>
<!-- @@@addMSecs -->
<!-- $$$addSecs[overload1]$$$addSecsint -->
<h3 class="fn" id="addSecs"><a name="addSecs"></a><span class="type"><a href="qtime.html#QTime">QTime</a></span> QTime::<span class="name">addSecs</span>(<span class="type">int</span> <i>s</i>) const</h3>
<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>
<p>Note that the time will wrap if it passes midnight.</p>
<p>Returns a null time if this time is invalid.</p>
<p>Example:</p>
<pre class="cpp">

  <span class="type"><a href="qtime.html#QTime">QTime</a></span> n(<span class="number">14</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span>);                <span class="comment">// n == 14:00:00</span>
  <span class="type"><a href="qtime.html#QTime">QTime</a></span> t;
  t <span class="operator">=</span> n<span class="operator">.</span>addSecs(<span class="number">70</span>);                <span class="comment">// t == 14:01:10</span>
  t <span class="operator">=</span> n<span class="operator">.</span>addSecs(<span class="operator">-</span><span class="number">70</span>);               <span class="comment">// t == 13:58:50</span>
  t <span class="operator">=</span> n<span class="operator">.</span>addSecs(<span class="number">10</span> <span class="operator">*</span> <span class="number">60</span> <span class="operator">*</span> <span class="number">60</span> <span class="operator">+</span> <span class="number">5</span>);  <span class="comment">// t == 00:00:05</span>
  t <span class="operator">=</span> n<span class="operator">.</span>addSecs(<span class="operator">-</span><span class="number">15</span> <span class="operator">*</span> <span class="number">60</span> <span class="operator">*</span> <span class="number">60</span>);     <span class="comment">// t == 23:00:00</span>

</pre>
<p><b>See also </b><a href="qtime.html#addMSecs">addMSecs</a>(), <a href="qtime.html#secsTo">secsTo</a>(), and <a href="qdatetime.html#addSecs">QDateTime::addSecs</a>().</p>
<!-- @@@addSecs -->
<!-- $$$currentTime[overload1]$$$currentTime -->
<h3 class="fn" id="currentTime"><a name="currentTime"></a><code>[static] </code><span class="type"><a href="qtime.html#QTime">QTime</a></span> QTime::<span class="name">currentTime</span>()</h3>
<p>Returns the current time as reported by the system clock.</p>
<p>Note that the accuracy depends on the accuracy of the underlying operating system; not all systems provide 1-millisecond accuracy.</p>
<!-- @@@currentTime -->
<!-- $$$elapsed[overload1]$$$elapsed -->
<h3 class="fn" id="elapsed"><a name="elapsed"></a><span class="type">int</span> QTime::<span class="name">elapsed</span>() const</h3>
<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>
<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>
<p>Note that the accuracy depends on the accuracy of the underlying operating system; not all systems provide 1-millisecond accuracy.</p>
<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-saving time is turned on or off.</p>
<p><b>See also </b><a href="qtime.html#start">start</a>() and <a href="qtime.html#restart">restart</a>().</p>
<!-- @@@elapsed -->
<!-- $$$fromMSecsSinceStartOfDay[overload1]$$$fromMSecsSinceStartOfDayint -->
<h3 class="fn" id="fromMSecsSinceStartOfDay"><a name="fromMSecsSinceStartOfDay"></a><code>[static] </code><span class="type"><a href="qtime.html#QTime">QTime</a></span> QTime::<span class="name">fromMSecsSinceStartOfDay</span>(<span class="type">int</span> <i>msecs</i>)</h3>
<p>Returns a new <a href="qtime.html">QTime</a> instance with the time set to the number of <i>msecs</i> since the start of the day, i.e&#x2e; since 00:00:00.</p>
<p>If <i>msecs</i> falls outside the valid range an invalid <a href="qtime.html">QTime</a> will be returned.</p>
<p><b>See also </b><a href="qtime.html#msecsSinceStartOfDay">msecsSinceStartOfDay</a>().</p>
<!-- @@@fromMSecsSinceStartOfDay -->
<!-- $$$fromString[overload1]$$$fromStringconstQString&Qt::DateFormat -->
<h3 class="fn" id="fromString"><a name="fromString"></a><code>[static] </code><span class="type"><a href="qtime.html#QTime">QTime</a></span> QTime::<span class="name">fromString</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>string</i>, <span class="type"><a href="qt.html#DateFormat-enum">Qt::DateFormat</a></span> <i>format</i> = Qt::TextDate)</h3>
<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>
<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>
<p><b>See also </b><a href="qtime.html#toString">toString</a>() and <a href="qlocale.html#toTime">QLocale::toTime</a>().</p>
<!-- @@@fromString -->
<!-- $$$fromString$$$fromStringconstQString&constQString& -->
<h3 class="fn" id="fromString-1"><a name="fromString-1"></a><code>[static] </code><span class="type"><a href="qtime.html#QTime">QTime</a></span> QTime::<span class="name">fromString</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>string</i>, const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>format</i>)</h3>
<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>
<p>These expressions may be used for the format:</p>
<div class="table"><table class="generic">
 <thead><tr class="qt-style"><th >Expression</th><th >Output</th></tr></thead>
<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>
<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>
<tr valign="top" class="odd"><td >m</td><td >the minute without a leading zero (0 to 59)</td></tr>
<tr valign="top" class="even"><td >mm</td><td >the minute with a leading zero (00 to 59)</td></tr>
<tr valign="top" class="odd"><td >s</td><td >the whole second, without any leading zero (0 to 59)</td></tr>
<tr valign="top" class="even"><td >ss</td><td >the whole second, with a leading zero where applicable (00 to 59)</td></tr>
<tr valign="top" class="odd"><td >z</td><td >the fractional part of the second, to go after a decimal point, without trailing zeroes (0 to 999). Thus &quot;<code>s.z</code>&quot; reports the seconds to full available (millisecond) precision without trailing zeroes.</td></tr>
<tr valign="top" class="even"><td >zzz</td><td >the fractional part of the second, to millisecond precision, including trailing zeroes where applicable (000 to 999).</td></tr>
<tr valign="top" class="odd"><td >AP</td><td >interpret as an AM/PM time. <i>AP</i> must be either &quot;AM&quot; or &quot;PM&quot;.</td></tr>
<tr valign="top" class="even"><td >ap</td><td >Interpret as an AM/PM time. <i>ap</i> must be either &quot;am&quot; or &quot;pm&quot;.</td></tr>
</table></div>
<p>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.</p>
<pre class="cpp">

  <span class="type"><a href="qtime.html#QTime">QTime</a></span> time <span class="operator">=</span> <span class="type"><a href="qtime.html#QTime">QTime</a></span><span class="operator">::</span>fromString(<span class="string">&quot;1mm12car00&quot;</span><span class="operator">,</span> <span class="string">&quot;m'mm'hcarss&quot;</span>);
  <span class="comment">// time is 12:01.00</span>

</pre>
<p>If the format is not satisfied, an invalid <a href="qtime.html">QTime</a> 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:</p>
<pre class="cpp">

  <span class="type"><a href="qtime.html#QTime">QTime</a></span> time <span class="operator">=</span> <span class="type"><a href="qtime.html#QTime">QTime</a></span><span class="operator">::</span>fromString(<span class="string">&quot;00:710&quot;</span><span class="operator">,</span> <span class="string">&quot;hh:ms&quot;</span>); <span class="comment">// invalid</span>

</pre>
<p>Any field that is not represented in the format will be set to zero. For example:</p>
<pre class="cpp">

  <span class="type"><a href="qtime.html#QTime">QTime</a></span> time <span class="operator">=</span> <span class="type"><a href="qtime.html#QTime">QTime</a></span><span class="operator">::</span>fromString(<span class="string">&quot;1.30&quot;</span><span class="operator">,</span> <span class="string">&quot;m.s&quot;</span>);
  <span class="comment">// time is 00:01:30.000</span>

</pre>
<p><b>See also </b><a href="qtime.html#toString">toString</a>(), <a href="qdatetime.html#fromString">QDateTime::fromString</a>(), <a href="qdate.html#fromString">QDate::fromString</a>(), and <a href="qlocale.html#toTime">QLocale::toTime</a>().</p>
<!-- @@@fromString -->
<!-- $$$hour[overload1]$$$hour -->
<h3 class="fn" id="hour"><a name="hour"></a><span class="type">int</span> QTime::<span class="name">hour</span>() const</h3>
<p>Returns the hour part (0 to 23) of the time.</p>
<p>Returns -1 if the time is invalid.</p>
<p><b>See also </b><a href="qtime.html#minute">minute</a>(), <a href="qtime.html#second">second</a>(), and <a href="qtime.html#msec">msec</a>().</p>
<!-- @@@hour -->
<!-- $$$isNull[overload1]$$$isNull -->
<h3 class="fn" id="isNull"><a name="isNull"></a><span class="type">bool</span> QTime::<span class="name">isNull</span>() const</h3>
<p>Returns <code>true</code> 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>
<p><b>See also </b><a href="qtime.html#isValid">isValid</a>().</p>
<!-- @@@isNull -->
<!-- $$$isValid[overload1]$$$isValid -->
<h3 class="fn" id="isValid"><a name="isValid"></a><span class="type">bool</span> QTime::<span class="name">isValid</span>() const</h3>
<p>Returns <code>true</code> if the time is valid; otherwise returns <code>false</code>. For example, the time 23:30:55.746 is valid, but 24:12:30 is invalid.</p>
<p><b>See also </b><a href="qtime.html#isNull">isNull</a>().</p>
<!-- @@@isValid -->
<!-- $$$isValid$$$isValidintintintint -->
<h3 class="fn" id="isValid-1"><a name="isValid-1"></a><code>[static] </code><span class="type">bool</span> QTime::<span class="name">isValid</span>(<span class="type">int</span> <i>h</i>, <span class="type">int</span> <i>m</i>, <span class="type">int</span> <i>s</i>, <span class="type">int</span> <i>ms</i> = 0)</h3>
<p>This is an overloaded function.</p>
<p>Returns <code>true</code> if the specified time is valid; otherwise returns false.</p>
<p>The time is valid if <i>h</i> is in the range 0 to 23, <i>m</i> and <i>s</i> are in the range 0 to 59, and <i>ms</i> is in the range 0 to 999.</p>
<p>Example:</p>
<pre class="cpp">

  <span class="type"><a href="qtime.html#QTime">QTime</a></span><span class="operator">::</span>isValid(<span class="number">21</span><span class="operator">,</span> <span class="number">10</span><span class="operator">,</span> <span class="number">30</span>); <span class="comment">// returns true</span>
  <span class="type"><a href="qtime.html#QTime">QTime</a></span><span class="operator">::</span>isValid(<span class="number">22</span><span class="operator">,</span> <span class="number">5</span><span class="operator">,</span>  <span class="number">62</span>); <span class="comment">// returns false</span>

</pre>
<!-- @@@isValid -->
<!-- $$$minute[overload1]$$$minute -->
<h3 class="fn" id="minute"><a name="minute"></a><span class="type">int</span> QTime::<span class="name">minute</span>() const</h3>
<p>Returns the minute part (0 to 59) of the time.</p>
<p>Returns -1 if the time is invalid.</p>
<p><b>See also </b><a href="qtime.html#hour">hour</a>(), <a href="qtime.html#second">second</a>(), and <a href="qtime.html#msec">msec</a>().</p>
<!-- @@@minute -->
<!-- $$$msec[overload1]$$$msec -->
<h3 class="fn" id="msec"><a name="msec"></a><span class="type">int</span> QTime::<span class="name">msec</span>() const</h3>
<p>Returns the millisecond part (0 to 999) of the time.</p>
<p>Returns -1 if the time is invalid.</p>
<p><b>See also </b><a href="qtime.html#hour">hour</a>(), <a href="qtime.html#minute">minute</a>(), and <a href="qtime.html#second">second</a>().</p>
<!-- @@@msec -->
<!-- $$$msecsSinceStartOfDay[overload1]$$$msecsSinceStartOfDay -->
<h3 class="fn" id="msecsSinceStartOfDay"><a name="msecsSinceStartOfDay"></a><span class="type">int</span> QTime::<span class="name">msecsSinceStartOfDay</span>() const</h3>
<p>Returns the number of msecs since the start of the day, i.e&#x2e; since 00:00:00.</p>
<p><b>See also </b><a href="qtime.html#fromMSecsSinceStartOfDay">fromMSecsSinceStartOfDay</a>().</p>
<!-- @@@msecsSinceStartOfDay -->
<!-- $$$msecsTo[overload1]$$$msecsToconstQTime& -->
<h3 class="fn" id="msecsTo"><a name="msecsTo"></a><span class="type">int</span> QTime::<span class="name">msecsTo</span>(const <span class="type"><a href="qtime.html#QTime">QTime</a></span> &amp;<i>t</i>) const</h3>
<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>
<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>
<p>Returns 0 if either time is invalid.</p>
<p><b>See also </b><a href="qtime.html#secsTo">secsTo</a>(), <a href="qtime.html#addMSecs">addMSecs</a>(), and <a href="qdatetime.html#msecsTo">QDateTime::msecsTo</a>().</p>
<!-- @@@msecsTo -->
<!-- $$$restart[overload1]$$$restart -->
<h3 class="fn" id="restart"><a name="restart"></a><span class="type">int</span> QTime::<span class="name">restart</span>()</h3>
<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>
<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>
<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>
<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-saving time is turned on or off.</p>
<p><b>See also </b><a href="qtime.html#start">start</a>(), <a href="qtime.html#elapsed">elapsed</a>(), and <a href="qtime.html#currentTime">currentTime</a>().</p>
<!-- @@@restart -->
<!-- $$$second[overload1]$$$second -->
<h3 class="fn" id="second"><a name="second"></a><span class="type">int</span> QTime::<span class="name">second</span>() const</h3>
<p>Returns the second part (0 to 59) of the time.</p>
<p>Returns -1 if the time is invalid.</p>
<p><b>See also </b><a href="qtime.html#hour">hour</a>(), <a href="qtime.html#minute">minute</a>(), and <a href="qtime.html#msec">msec</a>().</p>
<!-- @@@second -->
<!-- $$$secsTo[overload1]$$$secsToconstQTime& -->
<h3 class="fn" id="secsTo"><a name="secsTo"></a><span class="type">int</span> QTime::<span class="name">secsTo</span>(const <span class="type"><a href="qtime.html#QTime">QTime</a></span> &amp;<i>t</i>) const</h3>
<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>
<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>
<p>secsTo() does not take into account any milliseconds.</p>
<p>Returns 0 if either time is invalid.</p>
<p><b>See also </b><a href="qtime.html#addSecs">addSecs</a>() and <a href="qdatetime.html#secsTo">QDateTime::secsTo</a>().</p>
<!-- @@@secsTo -->
<!-- $$$setHMS[overload1]$$$setHMSintintintint -->
<h3 class="fn" id="setHMS"><a name="setHMS"></a><span class="type">bool</span> QTime::<span class="name">setHMS</span>(<span class="type">int</span> <i>h</i>, <span class="type">int</span> <i>m</i>, <span class="type">int</span> <i>s</i>, <span class="type">int</span> <i>ms</i> = 0)</h3>
<p>Sets the time to hour <i>h</i>, minute <i>m</i>, seconds <i>s</i> and milliseconds <i>ms</i>.</p>
<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 <code>true</code> if the set time is valid; otherwise returns <code>false</code>.</p>
<p><b>See also </b><a href="qtime.html#isValid">isValid</a>().</p>
<!-- @@@setHMS -->
<!-- $$$start[overload1]$$$start -->
<h3 class="fn" id="start"><a name="start"></a><span class="type">void</span> QTime::<span class="name">start</span>()</h3>
<p>Sets this time to the current time. This is practical for timing:</p>
<pre class="cpp">

  <span class="type"><a href="qtime.html#QTime">QTime</a></span> t;
  t<span class="operator">.</span>start();
  some_lengthy_task();
  <a href="qtglobal.html#qDebug">qDebug</a>(<span class="string">&quot;Time elapsed: %d ms&quot;</span><span class="operator">,</span> t<span class="operator">.</span>elapsed());

</pre>
<p><b>See also </b><a href="qtime.html#restart">restart</a>(), <a href="qtime.html#elapsed">elapsed</a>(), and <a href="qtime.html#currentTime">currentTime</a>().</p>
<!-- @@@start -->
<!-- $$$toString[overload1]$$$toStringconstQString& -->
<h3 class="fn" id="toString"><a name="toString"></a><span class="type"><a href="qstring.html">QString</a></span> QTime::<span class="name">toString</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>format</i>) const</h3>
<p>Returns the time as a string. The <i>format</i> parameter determines the format of the result string.</p>
<p>These expressions may be used:</p>
<div class="table"><table class="generic">
 <thead><tr class="qt-style"><th >Expression</th><th >Output</th></tr></thead>
<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>
<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>
<tr valign="top" class="odd"><td >H</td><td >the hour without a leading zero (0 to 23, even with AM/PM display)</td></tr>
<tr valign="top" class="even"><td >HH</td><td >the hour with a leading zero (00 to 23, even with AM/PM display)</td></tr>
<tr valign="top" class="odd"><td >m</td><td >the minute without a leading zero (0 to 59)</td></tr>
<tr valign="top" class="even"><td >mm</td><td >the minute with a leading zero (00 to 59)</td></tr>
<tr valign="top" class="odd"><td >s</td><td >the whole second, without any leading zero (0 to 59)</td></tr>
<tr valign="top" class="even"><td >ss</td><td >the whole second, with a leading zero where applicable (00 to 59)</td></tr>
<tr valign="top" class="odd"><td >z</td><td >the fractional part of the second, to go after a decimal point, without trailing zeroes (0 to 999). Thus &quot;<code>s.z</code>&quot; reports the seconds to full available (millisecond) precision without trailing zeroes.</td></tr>
<tr valign="top" class="even"><td >zzz</td><td >the fractional part of the second, to millisecond precision, including trailing zeroes where applicable (000 to 999).</td></tr>
<tr valign="top" class="odd"><td >AP or A</td><td >use AM/PM display. <i>A/AP</i> will be replaced by either <a href="qlocale.html#amText">QLocale::amText</a>() or <a href="qlocale.html#pmText">QLocale::pmText</a>().</td></tr>
<tr valign="top" class="even"><td >ap or a</td><td >use am/pm display. <i>a/ap</i> will be replaced by a lower-case version of <a href="qlocale.html#amText">QLocale::amText</a>() or <a href="qlocale.html#pmText">QLocale::pmText</a>().</td></tr>
<tr valign="top" class="odd"><td >t</td><td >the timezone (for example &quot;CEST&quot;)</td></tr>
</table></div>
<p>All other input characters will be ignored. Any sequence of characters that are enclosed in single quotes will be treated as text and not be used as an expression. Two consecutive single quotes (&quot;''&quot;) are replaced by a singlequote in the output. Formats without separators (e.g&#x2e; &quot;HHmm&quot;) are currently not supported.</p>
<p>Example format strings (assuming that the <a href="qtime.html">QTime</a> is 14:13:09.042 and the system locale is <code>en_US</code>)</p>
<div class="table"><table class="generic">
 <thead><tr class="qt-style"><th >Format</th><th >Result</th></tr></thead>
<tr valign="top" class="odd"><td >hh:mm:ss.zzz</td><td >14:13:09.042</td></tr>
<tr valign="top" class="even"><td >h:m:s ap</td><td >2:13:9 pm</td></tr>
<tr valign="top" class="odd"><td >H:m:s a</td><td >14:13:9 pm</td></tr>
</table></div>
<p>If the time is invalid, an empty string will be returned. If <i>format</i> is empty, the default format &quot;hh:mm:ss&quot; is used.</p>
<p><b>See also </b><a href="qtime.html#fromString">fromString</a>(), <a href="qdate.html#toString">QDate::toString</a>(), <a href="qdatetime.html#toString">QDateTime::toString</a>(), and <a href="qlocale.html#toString">QLocale::toString</a>().</p>
<!-- @@@toString -->
<!-- $$$toString$$$toStringQt::DateFormat -->
<h3 class="fn" id="toString-1"><a name="toString-1"></a><span class="type"><a href="qstring.html">QString</a></span> QTime::<span class="name">toString</span>(<span class="type"><a href="qt.html#DateFormat-enum">Qt::DateFormat</a></span> <i>format</i> = Qt::TextDate) const</h3>
<p>This is an overloaded function.</p>
<p>Returns the time as a string. The <i>format</i> parameter determines the format of the string.</p>
<p>If <i>format</i> is <a href="qt.html#DateFormat-enum">Qt::TextDate</a>, the string format is HH:mm:ss; e.g&#x2e; 1 second before midnight would be &quot;23:59:59&quot;.</p>
<p>If <i>format</i> is <a href="qt.html#DateFormat-enum">Qt::ISODate</a>, the string format corresponds to the ISO 8601 extended specification for representations of dates, represented by HH:mm:ss. To include milliseconds in the ISO 8601 date, use the <i>format</i> <a href="qt.html#DateFormat-enum">Qt::ISODateWithMs</a>, which corresponds to HH:mm:ss.zzz.</p>
<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>().<a href="qtime.html#toString">toString</a>(time, <a href="qlocale.html#FormatType-enum">QLocale::ShortFormat</a>) or <a href="qlocale.html#system">QLocale::system</a>().<a href="qtime.html#toString">toString</a>(time, <a href="qlocale.html#FormatType-enum">QLocale::LongFormat</a>).</p>
<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</p>
<p><a href="qlocale.html#toString">QLocale().toString(time, QLocale::ShortFormat)</a> or <a href="qlocale.html#toString">QLocale().toString(time, QLocale::LongFormat)</a>.</p>
<p>If the <i>format</i> is <a href="qt.html#DateFormat-enum">Qt::RFC2822Date</a>, the string is formatted in an RFC 2822 compatible way. An example of this formatting is &quot;23:59:20&quot;.</p>
<p>If the time is invalid, an empty string will be returned.</p>
<p><b>See also </b><a href="qtime.html#fromString">fromString</a>(), <a href="qdate.html#toString">QDate::toString</a>(), <a href="qdatetime.html#toString">QDateTime::toString</a>(), and <a href="qlocale.html#toString">QLocale::toString</a>().</p>
<!-- @@@toString -->
<!-- $$$operator!=[overload1]$$$operator!=constQTime& -->
<h3 class="fn" id="operator-not-eq"><a name="operator-not-eq"></a><span class="type">bool</span> QTime::<span class="name">operator!=</span>(const <span class="type"><a href="qtime.html#QTime">QTime</a></span> &amp;<i>t</i>) const</h3>
<p>Returns <code>true</code> if this time is different from <i>t</i>; otherwise returns <code>false</code>.</p>
<!-- @@@operator!= -->
<!-- $$$operator<[overload1]$$$operator<constQTime& -->
<h3 class="fn" id="operator-lt"><a name="operator-lt"></a><span class="type">bool</span> QTime::<span class="name">operator&lt;</span>(const <span class="type"><a href="qtime.html#QTime">QTime</a></span> &amp;<i>t</i>) const</h3>
<p>Returns <code>true</code> if this time is earlier than <i>t</i>; otherwise returns <code>false</code>.</p>
<!-- @@@operator< -->
<!-- $$$operator<=[overload1]$$$operator<=constQTime& -->
<h3 class="fn" id="operator-lt-eq"><a name="operator-lt-eq"></a><span class="type">bool</span> QTime::<span class="name">operator&lt;=</span>(const <span class="type"><a href="qtime.html#QTime">QTime</a></span> &amp;<i>t</i>) const</h3>
<p>Returns <code>true</code> if this time is earlier than or equal to <i>t</i>; otherwise returns <code>false</code>.</p>
<!-- @@@operator<= -->
<!-- $$$operator==[overload1]$$$operator==constQTime& -->
<h3 class="fn" id="operator-eq-eq"><a name="operator-eq-eq"></a><span class="type">bool</span> QTime::<span class="name">operator==</span>(const <span class="type"><a href="qtime.html#QTime">QTime</a></span> &amp;<i>t</i>) const</h3>
<p>Returns <code>true</code> if this time is equal to <i>t</i>; otherwise returns <code>false</code>.</p>
<!-- @@@operator== -->
<!-- $$$operator>[overload1]$$$operator>constQTime& -->
<h3 class="fn" id="operator-gt"><a name="operator-gt"></a><span class="type">bool</span> QTime::<span class="name">operator&gt;</span>(const <span class="type"><a href="qtime.html#QTime">QTime</a></span> &amp;<i>t</i>) const</h3>
<p>Returns <code>true</code> if this time is later than <i>t</i>; otherwise returns <code>false</code>.</p>
<!-- @@@operator> -->
<!-- $$$operator>=[overload1]$$$operator>=constQTime& -->
<h3 class="fn" id="operator-gt-eq"><a name="operator-gt-eq"></a><span class="type">bool</span> QTime::<span class="name">operator&gt;=</span>(const <span class="type"><a href="qtime.html#QTime">QTime</a></span> &amp;<i>t</i>) const</h3>
<p>Returns <code>true</code> if this time is later than or equal to <i>t</i>; otherwise returns <code>false</code>.</p>
<!-- @@@operator>= -->
</div>
<div class="relnonmem">
<h2>Related Non-Members</h2>
<!-- $$$operator<<[overload1]$$$operator<<QDataStream&constQTime& -->
<h3 class="fn" id="operator-lt-lt"><a name="operator-lt-lt"></a><span class="type"><a href="qdatastream.html">QDataStream</a></span> &amp;<span class="name">operator&lt;&lt;</span>(<span class="type"><a href="qdatastream.html">QDataStream</a></span> &amp;<i>out</i>, const <span class="type"><a href="qtime.html#QTime">QTime</a></span> &amp;<i>time</i>)</h3>
<p>Writes <i>time</i> to stream <i>out</i>.</p>
<p><b>See also </b><a href="datastreamformat.html">Serializing Qt Data Types</a>.</p>
<!-- @@@operator<< -->
<!-- $$$operator>>[overload1]$$$operator>>QDataStream&QTime& -->
<h3 class="fn" id="operator-gt-gt"><a name="operator-gt-gt"></a><span class="type"><a href="qdatastream.html">QDataStream</a></span> &amp;<span class="name">operator&gt;&gt;</span>(<span class="type"><a href="qdatastream.html">QDataStream</a></span> &amp;<i>in</i>, <span class="type"><a href="qtime.html#QTime">QTime</a></span> &amp;<i>time</i>)</h3>
<p>Reads a time from stream <i>in</i> into the given <i>time</i>.</p>
<p><b>See also </b><a href="datastreamformat.html">Serializing Qt Data Types</a>.</p>
<!-- @@@operator>> -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2017 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>