Sophie

Sophie

distrib > Mageia > 7 > i586 > by-pkgid > 1dd17e0d683ef79b4bb6872bbf359d7f > files > 5246

qt4-doc-4.8.7-26.2.mga7.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qelapsedtimer.cpp -->
  <title>Qt 4.8: QElapsedTimer Class Reference</title>
  <link rel="stylesheet" type="text/css" href="style/style.css" />
  <script src="scripts/jquery.js" type="text/javascript"></script>
  <script src="scripts/functions.js" type="text/javascript"></script>
  <link rel="stylesheet" type="text/css" href="style/superfish.css" />
  <link rel="stylesheet" type="text/css" href="style/narrow.css" />
  <!--[if IE]>
<meta name="MSSmartTagsPreventParsing" content="true">
<meta http-equiv="imagetoolbar" content="no">
<![endif]-->
<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" href="style/style_ie6.css">
<![endif]-->
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="style/style_ie7.css">
<![endif]-->
<!--[if IE 8]>
<link rel="stylesheet" type="text/css" href="style/style_ie8.css">
<![endif]-->

<script src="scripts/superfish.js" type="text/javascript"></script>
<script src="scripts/narrow.js" type="text/javascript"></script>

</head>
<body class="" onload="CheckEmptyAndLoadList();">
 <div class="header" id="qtdocheader">
    <div class="content"> 
    <div id="nav-logo">
      <a href="index.html">Home</a></div>
    <a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a>
    <div id="narrowsearch"></div>
    <div id="nav-topright">
      <ul>
        <li class="nav-topright-home"><a href="http://qt.digia.com/">Qt HOME</a></li>
        <li class="nav-topright-dev"><a href="http://qt-project.org/">DEV</a></li>
        <li class="nav-topright-doc nav-topright-doc-active"><a href="http://qt-project.org/doc/">
          DOC</a></li>
        <li class="nav-topright-blog"><a href="http://blog.qt.digia.com/">BLOG</a></li>
      </ul>
    </div>
    <div id="shortCut">
      <ul>
        <li class="shortCut-topleft-inactive"><span><a href="index.html">Qt 4.8</a></span></li>
        <li class="shortCut-topleft-active"><a href="http://qt-project.org/doc/">ALL VERSIONS        </a></li>
      </ul>
     </div>
 <ul class="sf-menu" id="narrowmenu"> 
             <li><a href="#">API Lookup</a> 
                 <ul> 
                     <li><a href="classes.html">Class index</a></li> 
           <li><a href="functions.html">Function index</a></li> 
           <li><a href="modules.html">Modules</a></li> 
           <li><a href="namespaces.html">Namespaces</a></li> 
           <li><a href="qtglobal.html">Global Declarations</a></li> 
           <li><a href="qdeclarativeelements.html">QML elements</a></li> 
             </ul> 
             </li> 
             <li><a href="#">Qt Topics</a> 
                 <ul> 
                        <li><a href="qt-basic-concepts.html">Programming with Qt</a></li>  
                        <li><a href="qtquick.html">Device UIs &amp; Qt Quick</a></li>  
                        <li><a href="qt-gui-concepts.html">UI Design with Qt</a></li>  
                        <li><a href="supported-platforms.html">Supported Platforms</a></li>  
                        <li><a href="technology-apis.html">Qt and Key Technologies</a></li>  
                        <li><a href="best-practices.html">How-To's and Best Practices</a></li>  
              </ul> 
                 </li> 
                 <li><a href="#">Examples</a> 
                     <ul> 
                       <li><a href="all-examples.html">Examples</a></li> 
                       <li><a href="tutorials.html">Tutorials</a></li> 
                       <li><a href="demos.html">Demos</a></li> 
                       <li><a href="qdeclarativeexamples.html">QML Examples</a></li> 
                </ul> 
                     </li> 
                 </ul> 
    </div>
  </div>
  <div class="wrapper">
    <div class="hd">
      <span></span>
    </div>
    <div class="bd group">
      <div class="sidebar">
        <div class="searchlabel">
          Search index:</div>
        <div class="search" id="sidebarsearch">
          <form id="qtdocsearch" action="" onsubmit="return false;">
            <fieldset>
              <input type="text" name="searchstring" id="pageType" value="" />
 <div id="resultdialog"> 
 <a href="#" id="resultclose">Close</a> 
 <p id="resultlinks" class="all"><a href="#" id="showallresults">All</a> | <a href="#" id="showapiresults">API</a> | <a href="#" id="showarticleresults">Articles</a> | <a href="#" id="showexampleresults">Examples</a></p> 
 <p id="searchcount" class="all"><span id="resultcount"></span><span id="apicount"></span><span id="articlecount"></span><span id="examplecount"></span>&nbsp;results:</p> 
 <ul id="resultlist" class="all"> 
 </ul> 
 </div> 
            </fieldset>
          </form>
        </div>
        <div class="box first bottombar" id="lookup">
          <h2 title="API Lookup"><span></span>
            API Lookup</h2>
          <div  id="list001" class="list">
          <ul id="ul001" >
              <li class="defaultLink"><a href="classes.html">Class index</a></li>
              <li class="defaultLink"><a href="functions.html">Function index</a></li>
              <li class="defaultLink"><a href="modules.html">Modules</a></li>
              <li class="defaultLink"><a href="namespaces.html">Namespaces</a></li>
              <li class="defaultLink"><a href="qtglobal.html">Global Declarations</a></li>
              <li class="defaultLink"><a href="qdeclarativeelements.html">QML elements</a></li>
            </ul> 
          </div>
        </div>
        <div class="box bottombar" id="topics">
          <h2 title="Qt Topics"><span></span>
            Qt Topics</h2>
          <div id="list002" class="list">
            <ul id="ul002" >
               <li class="defaultLink"><a href="qt-basic-concepts.html">Programming with Qt</a></li> 
               <li class="defaultLink"><a href="qtquick.html">Device UIs &amp; Qt Quick</a></li> 
               <li class="defaultLink"><a href="qt-gui-concepts.html">UI Design with Qt</a></li> 
               <li class="defaultLink"><a href="supported-platforms.html">Supported Platforms</a></li>  
               <li class="defaultLink"><a href="technology-apis.html">Qt and Key Technologies</a></li> 
               <li class="defaultLink"><a href="best-practices.html">How-To's and Best Practices</a></li> 
            </ul>  
          </div>
        </div>
        <div class="box" id="examples">
          <h2 title="Examples"><span></span>
            Examples</h2>
          <div id="list003" class="list">
        <ul id="ul003">
              <li class="defaultLink"><a href="all-examples.html">Examples</a></li>
              <li class="defaultLink"><a href="tutorials.html">Tutorials</a></li>
              <li class="defaultLink"><a href="demos.html">Demos</a></li>
              <li class="defaultLink"><a href="qdeclarativeexamples.html">QML Examples</a></li>
            </ul> 
          </div>
        </div>
      </div>
      <div class="wrap">
        <div class="toolbar">
          <div class="breadcrumb toolblock">
            <ul>
              <li class="first"><a href="index.html">Home</a></li>
              <!--  Breadcrumbs go here -->
<li><a href="modules.html">Modules</a></li>
<li><a href="qtcore.html">QtCore</a></li>
<li>QElapsedTimer</li>
            </ul>
          </div>
          <div class="toolbuttons toolblock">
            <ul>
              <li id="smallA" class="t_button">A</li>
              <li id="medA" class="t_button active">A</li>
              <li id="bigA" class="t_button">A</li>
              <li id="print" class="t_button"><a href="javascript:this.print();">
                <span>Print</span></a></li>
            </ul>
        </div>
        </div>
        <div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-types">Public Types</a></li>
<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="#details">Detailed Description</a></li>
<li class="level2"><a href="#reference-clocks">Reference clocks</a></li>
<li class="level3"><a href="#32-bit-overflows">32-bit overflows</a></li>
</ul>
</div>
<h1 class="title">QElapsedTimer Class Reference</h1>
<!-- $$$QElapsedTimer-brief -->
<p>The QElapsedTimer class provides a fast way to calculate elapsed times. <a href="#details">More...</a></p>
<!-- @@@QElapsedTimer -->
<pre class="cpp"> <span class="preprocessor">#include &lt;QElapsedTimer&gt;</span></pre><p><b>Note:</b> All functions in this class are <a href="threads-reentrancy.html#reentrant">reentrant</a>.</p>
<p>This class was introduced in Qt 4.7.</p>
<ul>
<li><a href="qelapsedtimer-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-types"></a>
<h2>Public Types</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qelapsedtimer.html#ClockType-enum">ClockType</a></b> { SystemTime, MonotonicClock, TickCounter, MachAbsoluteTime, PerformanceCounter }</td></tr>
</table>
<a name="public-functions"></a>
<h2>Public Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> qint64 </td><td class="memItemRight bottomAlign"><b><a href="qelapsedtimer.html#elapsed">elapsed</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qelapsedtimer.html#hasExpired">hasExpired</a></b> ( qint64 <i>timeout</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qelapsedtimer.html#invalidate">invalidate</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qelapsedtimer.html#isValid">isValid</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qint64 </td><td class="memItemRight bottomAlign"><b><a href="qelapsedtimer.html#msecsSinceReference">msecsSinceReference</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qint64 </td><td class="memItemRight bottomAlign"><b><a href="qelapsedtimer.html#msecsTo">msecsTo</a></b> ( const QElapsedTimer &amp; <i>other</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qint64 </td><td class="memItemRight bottomAlign"><b><a href="qelapsedtimer.html#nsecsElapsed">nsecsElapsed</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qint64 </td><td class="memItemRight bottomAlign"><b><a href="qelapsedtimer.html#restart">restart</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qint64 </td><td class="memItemRight bottomAlign"><b><a href="qelapsedtimer.html#secsTo">secsTo</a></b> ( const QElapsedTimer &amp; <i>other</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qelapsedtimer.html#start">start</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qelapsedtimer.html#operator-not-eq">operator!=</a></b> ( const QElapsedTimer &amp; <i>other</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qelapsedtimer.html#operator-eq-eq">operator==</a></b> ( const QElapsedTimer &amp; <i>other</i> ) const</td></tr>
</table>
<a name="static-public-members"></a>
<h2>Static Public Members</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> ClockType </td><td class="memItemRight bottomAlign"><b><a href="qelapsedtimer.html#clockType">clockType</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qelapsedtimer.html#isMonotonic">isMonotonic</a></b> ()</td></tr>
</table>
<a name="details"></a>
<!-- $$$QElapsedTimer-description -->
<div class="descr">
<h2>Detailed Description</h2>
<p>The QElapsedTimer class provides a fast way to calculate elapsed times.</p>
<p>The QElapsedTimer class is usually used to quickly calculate how much time has elapsed between two events. Its API is similar to that of <a href="qtime.html">QTime</a>, so code that was using that can be ported quickly to the new class.</p>
<p>However, unlike <a href="qtime.html">QTime</a>, QElapsedTimer tries to use monotonic clocks if possible. This means it's not possible to convert QElapsedTimer objects to a human-readable time.</p>
<p>The typical use-case for the class is to determine how much time was spent in a slow operation. The simplest example of such a case is for debugging purposes, as in the following example:</p>
<pre class="cpp">     <span class="type">QElapsedTimer</span> timer;
     timer<span class="operator">.</span>start();

     slowOperation1();

     <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;The slow operation took&quot;</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> timer<span class="operator">.</span>elapsed() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;milliseconds&quot;</span>;</pre>
<p>In this example, the timer is started by a call to <a href="qelapsedtimer.html#start">start</a>() and the elapsed timer is calculated by the <a href="qelapsedtimer.html#elapsed">elapsed</a>() function.</p>
<p>The time elapsed can also be used to recalculate the time available for another operation, after the first one is complete. This is useful when the execution must complete within a certain time period, but several steps are needed. The <tt>waitFor</tt>-type functions in <a href="qiodevice.html">QIODevice</a> and its subclasses are good examples of such need. In that case, the code could be as follows:</p>
<pre class="cpp"> <span class="type">void</span> executeSlowOperations(<span class="type">int</span> timeout)
 {
     <span class="type">QElapsedTimer</span> timer;
     timer<span class="operator">.</span>start();
     slowOperation1();

     <span class="type">int</span> remainingTime <span class="operator">=</span> timeout <span class="operator">-</span> timer<span class="operator">.</span>elapsed();
     <span class="keyword">if</span> (remainingTime <span class="operator">&gt;</span> <span class="number">0</span>)
         slowOperation2(remainingTime);
 }</pre>
<p>Another use-case is to execute a certain operation for a specific timeslice. For this, QElapsedTimer provides the <a href="qelapsedtimer.html#hasExpired">hasExpired</a>() convenience function, which can be used to determine if a certain number of milliseconds has already elapsed:</p>
<pre class="cpp"> <span class="type">void</span> executeOperationsForTime(<span class="type">int</span> ms)
 {
     <span class="type">QElapsedTimer</span> timer;
     timer<span class="operator">.</span>start();

     <span class="keyword">while</span> (<span class="operator">!</span>timer<span class="operator">.</span>hasExpired(ms))
         slowOperation1();
 }</pre>
<a name="reference-clocks"></a>
<h3>Reference clocks</h3>
<p>QElapsedTimer will use the platform's monotonic reference clock in all platforms that support it (see <a href="qelapsedtimer.html#isMonotonic">QElapsedTimer::isMonotonic</a>()). This has the added benefit that QElapsedTimer is immune to time adjustments, such as the user correcting the time. Also unlike <a href="qtime.html">QTime</a>, QElapsedTimer is immune to changes in the timezone settings, such as daylight savings periods.</p>
<p>On the other hand, this means QElapsedTimer values can only be compared with other values that use the same reference. This is especially true if the time since the reference is extracted from the QElapsedTimer object (<a href="qelapsedtimer.html#msecsSinceReference">QElapsedTimer::msecsSinceReference</a>()) and serialised. These values should never be exchanged across the network or saved to disk, since there's no telling whether the computer node receiving the data is the same as the one originating it or if it has rebooted since.</p>
<p>It is, however, possible to exchange the value with other processes running on the same machine, provided that they also use the same reference clock. QElapsedTimer will always use the same clock, so it's safe to compare with the value coming from another process in the same machine. If comparing to values produced by other APIs, you should check that the clock used is the same as QElapsedTimer (see <a href="qelapsedtimer.html#clockType">QElapsedTimer::clockType</a>()).</p>
<a name="32-bit-overflows"></a>
<h4>32-bit overflows</h4>
<p>Some of the clocks that QElapsedTimer have a limited range and may overflow after hitting the upper limit (usually 32-bit). QElapsedTimer deals with this overflow issue and presents a consistent timing. However, when extracting the time since reference from QElapsedTimer, two different processes in the same machine may have different understanding of how much time has actually elapsed.</p>
<p>The information on which clocks types may overflow and how to remedy that issue is documented along with the clock types.</p>
</div>
<p><b>See also </b><a href="qtime.html">QTime</a> and <a href="qtimer.html">QTimer</a>.</p>
<!-- @@@QElapsedTimer -->
<div class="types">
<h2>Member Type Documentation</h2>
<!-- $$$ClockType$$$SystemTime$$$MonotonicClock$$$TickCounter$$$MachAbsoluteTime$$$PerformanceCounter -->
<h3 class="fn"><a name="ClockType-enum"></a>enum QElapsedTimer::<span class="name">ClockType</span></h3>
<p>This enum contains the different clock types that <a href="qelapsedtimer.html">QElapsedTimer</a> may use.</p>
<p><a href="qelapsedtimer.html">QElapsedTimer</a> will always use the same clock type in a particular machine, so this value will not change during the lifetime of a program. It is provided so that <a href="qelapsedtimer.html">QElapsedTimer</a> can be used with other non-Qt implementations, to guarantee that the same reference clock is being used.</p>
<table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><tt>QElapsedTimer::SystemTime</tt></td><td class="topAlign"><tt>0</tt></td><td class="topAlign">The human-readable system time. This clock is not monotonic.</td></tr>
<tr><td class="topAlign"><tt>QElapsedTimer::MonotonicClock</tt></td><td class="topAlign"><tt>1</tt></td><td class="topAlign">The system's monotonic clock, usually found in Unix systems. This clock is monotonic and does not overflow.</td></tr>
<tr><td class="topAlign"><tt>QElapsedTimer::TickCounter</tt></td><td class="topAlign"><tt>2</tt></td><td class="topAlign">The system's tick counter, used on Windows and Symbian systems. This clock may overflow.</td></tr>
<tr><td class="topAlign"><tt>QElapsedTimer::MachAbsoluteTime</tt></td><td class="topAlign"><tt>3</tt></td><td class="topAlign">The Mach kernel's absolute time (Mac OS X). This clock is monotonic and does not overflow.</td></tr>
<tr><td class="topAlign"><tt>QElapsedTimer::PerformanceCounter</tt></td><td class="topAlign"><tt>4</tt></td><td class="topAlign">The high-resolution performance counter provided by Windows. This clock is monotonic and does not overflow.</td></tr>
</table>
<a name="systemtime"></a>
<h5>SystemTime</h5>
<p>The system time clock is purely the real time, expressed in milliseconds since Jan 1, 1970 at 0:00 UTC. It's equivalent to the value returned by the C and POSIX <tt>time</tt> function, with the milliseconds added. This clock type is currently only used on Unix systems that do not support monotonic clocks (see below).</p>
<p>This is the only non-monotonic clock that <a href="qelapsedtimer.html">QElapsedTimer</a> may use.</p>
<a name="monotonicclock"></a>
<h5>MonotonicClock</h5>
<p>This is the system's monotonic clock, expressed in milliseconds since an arbitrary point in the past. This clock type is used on Unix systems which support POSIX monotonic clocks (<tt>_POSIX_MONOTONIC_CLOCK</tt>).</p>
<p>This clock does not overflow.</p>
<a name="tickcounter"></a>
<h5>TickCounter</h5>
<p>The tick counter clock type is based on the system's or the processor's tick counter, multiplied by the duration of a tick. This clock type is used on Windows and Symbian platforms. If the high-precision performance counter is available on Windows, the <tt>PerformanceCounter</tt> clock type is used instead.</p>
<p>The TickCounter clock type is the only clock type that may overflow. Windows Vista and Windows Server 2008 support the extended 64-bit tick counter, which allows avoiding the overflow.</p>
<p>On Windows systems, the clock overflows after 2^32 milliseconds, which corresponds to roughly 49.7 days. This means two processes's reckoning of the time since the reference may be different by multiples of 2^32 milliseconds. When comparing such values, it's recommended that the high 32 bits of the millisecond count be masked off.</p>
<p>On Symbian systems, the overflow happens after 2^32 ticks, the duration of which can be obtained from the platform HAL using the constant HAL::ENanoTickPeriod. When comparing values between processes, it's necessary to divide the value by the tick duration and mask off the high 32 bits.</p>
<a name="machabsolutetime"></a>
<h5>MachAbsoluteTime</h5>
<p>This clock type is based on the absolute time presented by Mach kernels, such as that found on Mac OS X. This clock type is presented separately from MonotonicClock since Mac OS X is also a Unix system and may support a POSIX monotonic clock with values differing from the Mach absolute time.</p>
<p>This clock is monotonic and does not overflow.</p>
<a name="performancecounter"></a>
<h5>PerformanceCounter</h5>
<p>This clock uses the Windows functions <tt>QueryPerformanceCounter</tt> and <tt>QueryPerformanceFrequency</tt> to access the system's high-precision performance counter. Since this counter may not be available on all systems, <a href="qelapsedtimer.html">QElapsedTimer</a> will fall back to the <tt>TickCounter</tt> clock automatically, if this clock cannot be used.</p>
<p>This clock is monotonic and does not overflow.</p>
<p><b>See also </b><a href="qelapsedtimer.html#clockType">clockType</a>() and <a href="qelapsedtimer.html#isMonotonic">isMonotonic</a>().</p>
<!-- @@@ClockType -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$clockType[overload1]$$$clockType -->
<h3 class="fn"><a name="clockType"></a><span class="type"><a href="qelapsedtimer.html#ClockType-enum">ClockType</a></span> QElapsedTimer::<span class="name">clockType</span> ()<tt> [static]</tt></h3>
<p>Returns the clock type that this <a href="qelapsedtimer.html">QElapsedTimer</a> implementation uses.</p>
<p><b>See also </b><a href="qelapsedtimer.html#isMonotonic">isMonotonic</a>().</p>
<!-- @@@clockType -->
<!-- $$$elapsed[overload1]$$$elapsed -->
<h3 class="fn"><a name="elapsed"></a><span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span> QElapsedTimer::<span class="name">elapsed</span> () const</h3>
<p>Returns the number of milliseconds since this <a href="qelapsedtimer.html">QElapsedTimer</a> was last started. Calling this function in a <a href="qelapsedtimer.html">QElapsedTimer</a> that was invalidated will result in undefined results.</p>
<p><b>See also </b><a href="qelapsedtimer.html#start">start</a>(), <a href="qelapsedtimer.html#restart">restart</a>(), <a href="qelapsedtimer.html#hasExpired">hasExpired</a>(), and <a href="qelapsedtimer.html#invalidate">invalidate</a>().</p>
<!-- @@@elapsed -->
<!-- $$$hasExpired[overload1]$$$hasExpiredqint64 -->
<h3 class="fn"><a name="hasExpired"></a><span class="type">bool</span> QElapsedTimer::<span class="name">hasExpired</span> ( <span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span> <i>timeout</i> ) const</h3>
<p>Returns true if this <a href="qelapsedtimer.html">QElapsedTimer</a> has already expired by <i>timeout</i> milliseconds (that is, more than <i>timeout</i> milliseconds have elapsed). The value of <i>timeout</i> can be -1 to indicate that this timer does not expire, in which case this function will always return false.</p>
<p><b>See also </b><a href="qelapsedtimer.html#elapsed">elapsed</a>().</p>
<!-- @@@hasExpired -->
<!-- $$$invalidate[overload1]$$$invalidate -->
<h3 class="fn"><a name="invalidate"></a><span class="type">void</span> QElapsedTimer::<span class="name">invalidate</span> ()</h3>
<p>Marks this <a href="qelapsedtimer.html">QElapsedTimer</a> object as invalid.</p>
<p>An invalid object can be checked with <a href="qelapsedtimer.html#isValid">isValid</a>(). Calculations of timer elapsed since invalid data are undefined and will likely produce bizarre results.</p>
<p><b>See also </b><a href="qelapsedtimer.html#isValid">isValid</a>(), <a href="qelapsedtimer.html#start">start</a>(), and <a href="qelapsedtimer.html#restart">restart</a>().</p>
<!-- @@@invalidate -->
<!-- $$$isMonotonic[overload1]$$$isMonotonic -->
<h3 class="fn"><a name="isMonotonic"></a><span class="type">bool</span> QElapsedTimer::<span class="name">isMonotonic</span> ()<tt> [static]</tt></h3>
<p>Returns true if this is a monotonic clock, false otherwise. See the information on the different clock types to understand which ones are monotonic.</p>
<p><b>See also </b><a href="qelapsedtimer.html#clockType">clockType</a>() and <a href="qelapsedtimer.html#ClockType-enum">QElapsedTimer::ClockType</a>.</p>
<!-- @@@isMonotonic -->
<!-- $$$isValid[overload1]$$$isValid -->
<h3 class="fn"><a name="isValid"></a><span class="type">bool</span> QElapsedTimer::<span class="name">isValid</span> () const</h3>
<p>Returns false if this object was invalidated by a call to <a href="qelapsedtimer.html#invalidate">invalidate</a>() and has not been restarted since.</p>
<p><b>See also </b><a href="qelapsedtimer.html#invalidate">invalidate</a>(), <a href="qelapsedtimer.html#start">start</a>(), and <a href="qelapsedtimer.html#restart">restart</a>().</p>
<!-- @@@isValid -->
<!-- $$$msecsSinceReference[overload1]$$$msecsSinceReference -->
<h3 class="fn"><a name="msecsSinceReference"></a><span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span> QElapsedTimer::<span class="name">msecsSinceReference</span> () const</h3>
<p>Returns the number of milliseconds between last time this <a href="qelapsedtimer.html">QElapsedTimer</a> object was started and its reference clock's start.</p>
<p>This number is usually arbitrary for all clocks except the <a href="qelapsedtimer.html#ClockType-enum">QElapsedTimer::SystemTime</a> clock. For that clock type, this number is the number of milliseconds since January 1st, 1970 at 0:00 UTC (that is, it is the Unix time expressed in milliseconds).</p>
<p><b>See also </b><a href="qelapsedtimer.html#clockType">clockType</a>() and <a href="qelapsedtimer.html#elapsed">elapsed</a>().</p>
<!-- @@@msecsSinceReference -->
<!-- $$$msecsTo[overload1]$$$msecsToconstQElapsedTimer& -->
<h3 class="fn"><a name="msecsTo"></a><span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span> QElapsedTimer::<span class="name">msecsTo</span> ( const <span class="type">QElapsedTimer</span> &amp; <i>other</i> ) const</h3>
<p>Returns the number of milliseconds between this <a href="qelapsedtimer.html">QElapsedTimer</a> and <i>other</i>. If <i>other</i> was started before this object, the returned value will be positive. If it was started later, the returned value will be negative.</p>
<p>The return value is undefined if this object or <i>other</i> were invalidated.</p>
<p><b>See also </b><a href="qelapsedtimer.html#secsTo">secsTo</a>() and <a href="qelapsedtimer.html#elapsed">elapsed</a>().</p>
<!-- @@@msecsTo -->
<!-- $$$nsecsElapsed[overload1]$$$nsecsElapsed -->
<h3 class="fn"><a name="nsecsElapsed"></a><span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span> QElapsedTimer::<span class="name">nsecsElapsed</span> () const</h3>
<p>Returns the number of nanoseconds since this <a href="qelapsedtimer.html">QElapsedTimer</a> was last started. Calling this function in a <a href="qelapsedtimer.html">QElapsedTimer</a> that was invalidated will result in undefined results.</p>
<p>On platforms that do not provide nanosecond resolution, the value returned will be the best estimate available.</p>
<p>This function was introduced in Qt 4.8.</p>
<p><b>See also </b><a href="qelapsedtimer.html#start">start</a>(), <a href="qelapsedtimer.html#restart">restart</a>(), <a href="qelapsedtimer.html#hasExpired">hasExpired</a>(), and <a href="qelapsedtimer.html#invalidate">invalidate</a>().</p>
<!-- @@@nsecsElapsed -->
<!-- $$$restart[overload1]$$$restart -->
<h3 class="fn"><a name="restart"></a><span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span> QElapsedTimer::<span class="name">restart</span> ()</h3>
<p>Restarts the timer and returns the time elapsed since the previous start. This function is equivalent to obtaining the elapsed time with <a href="qelapsedtimer.html#elapsed">elapsed</a>() and then starting the timer again with <a href="qelapsedtimer.html#start">start</a>(), but it does so in one single operation, avoiding the need to obtain the clock value twice.</p>
<p>The following example illustrates how to use this function to calibrate a parameter to a slow operation (for example, an iteration count) so that this operation takes at least 250 milliseconds:</p>
<pre class="cpp">     <span class="type"><a href="qelapsedtimer.html">QElapsedTimer</a></span> timer;

     <span class="type">int</span> count <span class="operator">=</span> <span class="number">1</span>;
     timer<span class="operator">.</span>start();
     <span class="keyword">do</span> {
         count <span class="operator">*</span><span class="operator">=</span> <span class="number">2</span>;
         slowOperation2(count);
     } <span class="keyword">while</span> (timer<span class="operator">.</span>restart() <span class="operator">&lt;</span> <span class="number">250</span>);

     <span class="keyword">return</span> count;</pre>
<p><b>See also </b><a href="qelapsedtimer.html#start">start</a>(), <a href="qelapsedtimer.html#invalidate">invalidate</a>(), and <a href="qelapsedtimer.html#elapsed">elapsed</a>().</p>
<!-- @@@restart -->
<!-- $$$secsTo[overload1]$$$secsToconstQElapsedTimer& -->
<h3 class="fn"><a name="secsTo"></a><span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span> QElapsedTimer::<span class="name">secsTo</span> ( const <span class="type">QElapsedTimer</span> &amp; <i>other</i> ) const</h3>
<p>Returns the number of seconds between this <a href="qelapsedtimer.html">QElapsedTimer</a> and <i>other</i>. If <i>other</i> was started before this object, the returned value will be positive. If it was started later, the returned value will be negative.</p>
<p>The return value is undefined if this object or <i>other</i> were invalidated.</p>
<p><b>See also </b><a href="qelapsedtimer.html#msecsTo">msecsTo</a>() and <a href="qelapsedtimer.html#elapsed">elapsed</a>().</p>
<!-- @@@secsTo -->
<!-- $$$start[overload1]$$$start -->
<h3 class="fn"><a name="start"></a><span class="type">void</span> QElapsedTimer::<span class="name">start</span> ()</h3>
<p>Starts this timer. Once started, a timer value can be checked with <a href="qelapsedtimer.html#elapsed">elapsed</a>() or <a href="qelapsedtimer.html#msecsSinceReference">msecsSinceReference</a>().</p>
<p>Normally, a timer is started just before a lengthy operation, such as:</p>
<pre class="cpp">     <span class="type"><a href="qelapsedtimer.html">QElapsedTimer</a></span> timer;
     timer<span class="operator">.</span>start();

     slowOperation1();

     <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;The slow operation took&quot;</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> timer<span class="operator">.</span>elapsed() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;milliseconds&quot;</span>;</pre>
<p>Also, starting a timer makes it valid again.</p>
<p><b>See also </b><a href="qelapsedtimer.html#restart">restart</a>(), <a href="qelapsedtimer.html#invalidate">invalidate</a>(), and <a href="qelapsedtimer.html#elapsed">elapsed</a>().</p>
<!-- @@@start -->
<!-- $$$operator!=[overload1]$$$operator!=constQElapsedTimer& -->
<h3 class="fn"><a name="operator-not-eq"></a><span class="type">bool</span> QElapsedTimer::<span class="name">operator!=</span> ( const <span class="type">QElapsedTimer</span> &amp; <i>other</i> ) const</h3>
<p>Returns true if this object and <i>other</i> contain different times.</p>
<!-- @@@operator!= -->
<!-- $$$operator==[overload1]$$$operator==constQElapsedTimer& -->
<h3 class="fn"><a name="operator-eq-eq"></a><span class="type">bool</span> QElapsedTimer::<span class="name">operator==</span> ( const <span class="type">QElapsedTimer</span> &amp; <i>other</i> ) const</h3>
<p>Returns true if this object and <i>other</i> contain the same time.</p>
<!-- @@@operator== -->
</div>
      </div>
    </div>
    </div> 
    <div class="ft">
      <span></span>
    </div>
  </div> 
  <div class="footer">
    <p>
      <acronym title="Copyright">&copy;</acronym> 2015 The Qt Company Ltd.
      Documentation contributions included herein are the copyrights of
      their respective owners.</p>
    <br />
    <p>
      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.</p>
    <p>
      Documentation sources may be obtained from <a href="http://www.qt-project.org">
      www.qt-project.org</a>.</p>
    <br />
    <p>
      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. <a title="Privacy Policy"
      href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p>
  </div>

  <script src="scripts/functions.js" type="text/javascript"></script>
</body>
</html>