<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- qbasictimer.cpp --> <title>QBasicTimer Class | Qt Core 5.11</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 ><a href="../qtdoc/index.html">Qt 5.11</a></td><td ><a href="qtcore-index.html">Qt Core</a></td><td ><a href="qtcore-module.html">C++ Classes</a></td><td >QBasicTimer</td></tr></table><table class="buildversion"><tr> <td id="buildversion" width="100%" align="right">Qt 5.11.2 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="#details">Detailed Description</a></li> </ul> </div> <div class="sidebar-content" id="sidebar-content"></div></div> <h1 class="title">QBasicTimer Class</h1> <!-- $$$QBasicTimer-brief --> <p>The <a href="qbasictimer.html">QBasicTimer</a> class provides timer events for objects. <a href="#details">More...</a></p> <!-- @@@QBasicTimer --> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include <QBasicTimer></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="qbasictimer-members.html">List of all members, including inherited members</a></li> </ul> <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="qbasictimer.html#QBasicTimer">QBasicTimer</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qbasictimer.html#dtor.QBasicTimer">~QBasicTimer</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qbasictimer.html#isActive">isActive</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qbasictimer.html#start">start</a></b>(int <i>msec</i>, QObject *<i>object</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qbasictimer.html#start-1">start</a></b>(int <i>msec</i>, Qt::TimerType <i>timerType</i>, QObject *<i>obj</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qbasictimer.html#stop">stop</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qbasictimer.html#timerId">timerId</a></b>() const</td></tr> </table></div> <a name="details"></a> <!-- $$$QBasicTimer-description --> <div class="descr"> <h2 id="details">Detailed Description</h2> <p>The <a href="qbasictimer.html">QBasicTimer</a> class provides timer events for objects.</p> <p>This is a fast, lightweight, and low-level class used by Qt internally. We recommend using the higher-level <a href="qtimer.html">QTimer</a> class rather than this class if you want to use timers in your applications. Note that this timer is a repeating timer that will send subsequent timer events unless the <a href="qbasictimer.html#stop">stop</a>() function is called.</p> <p>To use this class, create a <a href="qbasictimer.html">QBasicTimer</a>, and call its <a href="qbasictimer.html#start">start</a>() function with a timeout interval and with a pointer to a <a href="qobject.html">QObject</a> subclass. When the timer times out it will send a timer event to the <a href="qobject.html">QObject</a> subclass. The timer can be stopped at any time using <a href="qbasictimer.html#stop">stop</a>(). <a href="qbasictimer.html#isActive">isActive</a>() returns <code>true</code> for a timer that is running; i.e. it has been started, has not reached the timeout time, and has not been stopped. The timer's ID can be retrieved using <a href="qbasictimer.html#timerId">timerId</a>().</p> <p>The <a href="../qtwidgets/qtwidgets-widgets-wiggly-example.html">Wiggly</a> example uses <a href="qbasictimer.html">QBasicTimer</a> to repaint a widget at regular intervals.</p> </div> <p><b>See also </b><a href="qtimer.html">QTimer</a>, <a href="qtimerevent.html">QTimerEvent</a>, <a href="qobject.html#timerEvent">QObject::timerEvent</a>(), <a href="timers.html">Timers</a>, and <a href="../qtwidgets/qtwidgets-widgets-wiggly-example.html">Wiggly Example</a>.</p> <!-- @@@QBasicTimer --> <div class="func"> <h2>Member Function Documentation</h2> <!-- $$$QBasicTimer[overload1]$$$QBasicTimer --> <h3 class="fn" id="QBasicTimer"><a name="QBasicTimer"></a>QBasicTimer::<span class="name">QBasicTimer</span>()</h3> <p>Contructs a basic timer.</p> <p><b>See also </b><a href="qbasictimer.html#start">start</a>().</p> <!-- @@@QBasicTimer --> <!-- $$$~QBasicTimer[overload1]$$$~QBasicTimer --> <h3 class="fn" id="dtor.QBasicTimer"><a name="dtor.QBasicTimer"></a>QBasicTimer::<span class="name">~QBasicTimer</span>()</h3> <p>Destroys the basic timer.</p> <!-- @@@~QBasicTimer --> <!-- $$$isActive[overload1]$$$isActive --> <h3 class="fn" id="isActive"><a name="isActive"></a><span class="type">bool</span> QBasicTimer::<span class="name">isActive</span>() const</h3> <p>Returns <code>true</code> if the timer is running and has not been stopped; otherwise returns <code>false</code>.</p> <p><b>See also </b><a href="qbasictimer.html#start">start</a>() and <a href="qbasictimer.html#stop">stop</a>().</p> <!-- @@@isActive --> <!-- $$$start[overload1]$$$startintQObject* --> <h3 class="fn" id="start"><a name="start"></a><span class="type">void</span> QBasicTimer::<span class="name">start</span>(<span class="type">int</span> <i>msec</i>, <span class="type"><a href="qobject.html">QObject</a></span> *<i>object</i>)</h3> <p>Starts (or restarts) the timer with a <i>msec</i> milliseconds timeout. The timer will be a <a href="qt.html#TimerType-enum">Qt::CoarseTimer</a>. See <a href="qt.html#TimerType-enum">Qt::TimerType</a> for information on the different timer types.</p> <p>The given <i>object</i> will receive timer events.</p> <p><b>See also </b><a href="qbasictimer.html#stop">stop</a>(), <a href="qbasictimer.html#isActive">isActive</a>(), <a href="qobject.html#timerEvent">QObject::timerEvent</a>(), and <a href="qt.html#TimerType-enum">Qt::CoarseTimer</a>.</p> <!-- @@@start --> <!-- $$$start$$$startintQt::TimerTypeQObject* --> <h3 class="fn" id="start-1"><a name="start-1"></a><span class="type">void</span> QBasicTimer::<span class="name">start</span>(<span class="type">int</span> <i>msec</i>, <span class="type">Qt::TimerType</span> <i>timerType</i>, <span class="type"><a href="qobject.html">QObject</a></span> *<i>obj</i>)</h3> <p>This is an overloaded function.</p> <p>Starts (or restarts) the timer with a <i>msec</i> milliseconds timeout and the given <i>timerType</i>. See <a href="qt.html#TimerType-enum">Qt::TimerType</a> for information on the different timer types.</p> <p><i>obj</i> will receive timer events.</p> <p><b>See also </b><a href="qbasictimer.html#stop">stop</a>(), <a href="qbasictimer.html#isActive">isActive</a>(), <a href="qobject.html#timerEvent">QObject::timerEvent</a>(), and <a href="qt.html#TimerType-enum">Qt::TimerType</a>.</p> <!-- @@@start --> <!-- $$$stop[overload1]$$$stop --> <h3 class="fn" id="stop"><a name="stop"></a><span class="type">void</span> QBasicTimer::<span class="name">stop</span>()</h3> <p>Stops the timer.</p> <p><b>See also </b><a href="qbasictimer.html#start">start</a>() and <a href="qbasictimer.html#isActive">isActive</a>().</p> <!-- @@@stop --> <!-- $$$timerId[overload1]$$$timerId --> <h3 class="fn" id="timerId"><a name="timerId"></a><span class="type">int</span> QBasicTimer::<span class="name">timerId</span>() const</h3> <p>Returns the timer's ID.</p> <p><b>See also </b><a href="qtimerevent.html#timerId">QTimerEvent::timerId</a>().</p> <!-- @@@timerId --> </div> </div> </div> </div> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2018 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>