<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- qtimeline.cpp --> <title>QTimeLine Class | Qt Core 5.12.6</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.12</td><td ><a href="qtcore-index.html">Qt Core</a></td><td ><a href="qtcore-module.html">C++ Classes</a></td><td >QTimeLine</td></tr></table><table class="buildversion"><tr> <td id="buildversion" width="100%" align="right"><a href="qtcore-index.html">Qt 5.12.6 Reference Documentation</a></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-types">Public Types</a></li> <li class="level1"><a href="#properties">Properties</a></li> <li class="level1"><a href="#public-functions">Public Functions</a></li> <li class="level1"><a href="#public-slots">Public Slots</a></li> <li class="level1"><a href="#signals">Signals</a></li> <li class="level1"><a href="#static-public-members">Static Public Members</a></li> <li class="level1"><a href="#reimplemented-protected-functions">Reimplemented Protected 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">QTimeLine Class</h1> <!-- $$$QTimeLine-brief --> <p>The <a href="qtimeline.html">QTimeLine</a> class provides a timeline for controlling animations. <a href="#details">More...</a></p> <!-- @@@QTimeLine --> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include <QTimeLine></span> </td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += core</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Since:</td><td class="memItemRight bottomAlign"> Qt 4.2</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherits:</td><td class="memItemRight bottomAlign"> <a href="qobject.html">QObject</a></td></tr></table></div><ul> <li><a href="qtimeline-members.html">List of all members, including inherited members</a></li> <li><a href="qtimeline-obsolete.html">Obsolete members</a></li> </ul> <a name="public-types"></a> <h2 id="public-types">Public Types</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#CurveShape-enum">CurveShape</a></b> { EaseInCurve, EaseOutCurve, EaseInOutCurve, LinearCurve, SineCurve, CosineCurve }</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#Direction-enum">Direction</a></b> { Forward, Backward }</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#State-enum">State</a></b> { NotRunning, Paused, Running }</td></tr> </table></div> <a name="properties"></a> <h2 id="properties">Properties</h2> <div class="table"><table class="propsummary"> <tr><td class="topAlign"><ul> <li class="fn"><b><a href="qtimeline.html#currentTime-prop">currentTime</a></b> : int</li> <li class="fn"><b><a href="qtimeline.html#curveShape-prop">curveShape</a></b> : CurveShape</li> <li class="fn"><b><a href="qtimeline.html#direction-prop">direction</a></b> : Direction</li> <li class="fn"><b><a href="qtimeline.html#duration-prop">duration</a></b> : int</li> </ul></td><td class="topAlign"><ul> <li class="fn"><b><a href="qtimeline.html#easingCurve-prop">easingCurve</a></b> : QEasingCurve</li> <li class="fn"><b><a href="qtimeline.html#loopCount-prop">loopCount</a></b> : int</li> <li class="fn"><b><a href="qtimeline.html#updateInterval-prop">updateInterval</a></b> : int</li> </ul> </td></tr> </table></div> <ul> <li class="fn">1 property inherited from <a href="qobject.html#properties">QObject</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="qtimeline.html#QTimeLine">QTimeLine</a></b>(int <i>duration</i> = 1000, QObject *<i>parent</i> = nullptr)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#dtor.QTimeLine">~QTimeLine</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#currentFrame">currentFrame</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#currentTime-prop">currentTime</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> qreal </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#currentValue">currentValue</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QTimeLine::CurveShape </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#curveShape-prop">curveShape</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QTimeLine::Direction </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#direction-prop">direction</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#duration-prop">duration</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QEasingCurve </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#easingCurve-prop">easingCurve</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#endFrame">endFrame</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#frameForTime">frameForTime</a></b>(int <i>msec</i>) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#loopCount-prop">loopCount</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#curveShape-prop">setCurveShape</a></b>(QTimeLine::CurveShape <i>shape</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#direction-prop">setDirection</a></b>(QTimeLine::Direction <i>direction</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#duration-prop">setDuration</a></b>(int <i>duration</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#easingCurve-prop">setEasingCurve</a></b>(const QEasingCurve &<i>curve</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#setEndFrame">setEndFrame</a></b>(int <i>frame</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#setFrameRange">setFrameRange</a></b>(int <i>startFrame</i>, int <i>endFrame</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#loopCount-prop">setLoopCount</a></b>(int <i>count</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#setStartFrame">setStartFrame</a></b>(int <i>frame</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#updateInterval-prop">setUpdateInterval</a></b>(int <i>interval</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#startFrame">startFrame</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QTimeLine::State </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#state">state</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#updateInterval-prop">updateInterval</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual qreal </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#valueForTime">valueForTime</a></b>(int <i>msec</i>) const</td></tr> </table></div> <ul> <li class="fn">32 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li> </ul> <a name="public-slots"></a> <h2 id="public-slots">Public Slots</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#resume">resume</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#currentTime-prop">setCurrentTime</a></b>(int <i>msec</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#setPaused">setPaused</a></b>(bool <i>paused</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#start">start</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#stop">stop</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#toggleDirection">toggleDirection</a></b>()</td></tr> </table></div> <ul> <li class="fn">1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li> </ul> <a name="signals"></a> <h2 id="signals">Signals</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#finished">finished</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#frameChanged">frameChanged</a></b>(int <i>frame</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#stateChanged">stateChanged</a></b>(QTimeLine::State <i>newState</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#valueChanged">valueChanged</a></b>(qreal <i>value</i>)</td></tr> </table></div> <ul> <li class="fn">2 signals inherited from <a href="qobject.html#signals">QObject</a></li> </ul> <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"> const QMetaObject </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#staticMetaObject-var">staticMetaObject</a></b></td></tr> </table></div> <ul> <li class="fn">10 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li> </ul> <a name="reimplemented-protected-functions"></a> <h2 id="reimplemented-protected-functions">Reimplemented Protected Functions</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qtimeline.html#timerEvent">timerEvent</a></b>(QTimerEvent *<i>event</i>) override</td></tr> </table></div> <ul> <li class="fn">9 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li> </ul> <a name="details"></a> <!-- $$$QTimeLine-description --> <div class="descr"> <h2 id="details">Detailed Description</h2> <p>The <a href="qtimeline.html">QTimeLine</a> class provides a timeline for controlling animations.</p> <p>It's most commonly used to animate a GUI control by calling a slot periodically. You can construct a timeline by passing its duration in milliseconds to <a href="qtimeline.html">QTimeLine</a>'s constructor. The timeline's duration describes for how long the animation will run. Then you set a suitable frame range by calling <a href="qtimeline.html#setFrameRange">setFrameRange</a>(). Finally connect the <a href="qtimeline.html#frameChanged">frameChanged</a>() signal to a suitable slot in the widget you wish to animate (for example, <a href="../qtwidgets/qprogressbar.html#value-prop">setValue()</a> in <a href="../qtwidgets/qprogressbar.html">QProgressBar</a>). When you proceed to calling <a href="qtimeline.html#start">start</a>(), <a href="qtimeline.html">QTimeLine</a> will enter Running state, and start emitting <a href="qtimeline.html#frameChanged">frameChanged</a>() at regular intervals, causing your widget's connected property's value to grow from the lower end to the upper and of your frame range, at a steady rate. You can specify the update interval by calling <a href="qtimeline.html#updateInterval-prop">setUpdateInterval</a>(). When done, <a href="qtimeline.html">QTimeLine</a> enters <a href="qtimeline.html#State-enum">NotRunning</a> state, and emits <a href="qtimeline.html#finished">finished</a>().</p> <p>Example:</p> <pre class="cpp"> <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span> progressBar <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="../qtwidgets/qprogressbar.html">QProgressBar</a></span>(<span class="keyword">this</span>); progressBar<span class="operator">-</span><span class="operator">></span>setRange(<span class="number">0</span><span class="operator">,</span> <span class="number">100</span>); <span class="comment">// Construct a 1-second timeline with a frame range of 0 - 100</span> <span class="type"><a href="qtimeline.html#QTimeLine">QTimeLine</a></span> <span class="operator">*</span>timeLine <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qtimeline.html#QTimeLine">QTimeLine</a></span>(<span class="number">1000</span><span class="operator">,</span> <span class="keyword">this</span>); timeLine<span class="operator">-</span><span class="operator">></span>setFrameRange(<span class="number">0</span><span class="operator">,</span> <span class="number">100</span>); connect(timeLine<span class="operator">,</span> SIGNAL(frameChanged(<span class="type">int</span>))<span class="operator">,</span> progressBar<span class="operator">,</span> SLOT(setValue(<span class="type">int</span>))); <span class="comment">// Clicking the push button will start the progress bar animation</span> pushButton <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="../qtwidgets/qpushbutton.html">QPushButton</a></span>(tr(<span class="string">"Start animation"</span>)<span class="operator">,</span> <span class="keyword">this</span>); connect(pushButton<span class="operator">,</span> SIGNAL(clicked())<span class="operator">,</span> timeLine<span class="operator">,</span> SLOT(start())); <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span> </pre> <p>By default the timeline runs once, from the beginning and towards the end, upon which you must call <a href="qtimeline.html#start">start</a>() again to restart from the beginning. To make the timeline loop, you can call <a href="qtimeline.html#loopCount-prop">setLoopCount</a>(), passing the number of times the timeline should run before finishing. The direction can also be changed, causing the timeline to run backward, by calling <a href="qtimeline.html#direction-prop">setDirection</a>(). You can also pause and unpause the timeline while it's running by calling <a href="qtimeline.html#setPaused">setPaused</a>(). For interactive control, the <a href="qtimeline.html#currentTime-prop">setCurrentTime</a>() function is provided, which sets the time position of the time line directly. Although most useful in <a href="qtimeline.html#State-enum">NotRunning</a> state, (e.g., connected to a <a href="qtimeline.html#valueChanged">valueChanged</a>() signal in a <a href="../qtwidgets/qslider.html">QSlider</a>,) this function can be called at any time.</p> <p>The frame interface is useful for standard widgets, but <a href="qtimeline.html">QTimeLine</a> can be used to control any type of animation. The heart of <a href="qtimeline.html">QTimeLine</a> lies in the <a href="qtimeline.html#valueForTime">valueForTime</a>() function, which generates a <i>value</i> between 0 and 1 for a given time. This value is typically used to describe the steps of an animation, where 0 is the first step of an animation, and 1 is the last step. When running, <a href="qtimeline.html">QTimeLine</a> generates values between 0 and 1 by calling <a href="qtimeline.html#valueForTime">valueForTime</a>() and emitting <a href="qtimeline.html#valueChanged">valueChanged</a>(). By default, <a href="qtimeline.html#valueForTime">valueForTime</a>() applies an interpolation algorithm to generate these value. You can choose from a set of predefined timeline algorithms by calling <a href="qtimeline.html#curveShape-prop">setCurveShape</a>().</p> <p>Note that by default, <a href="qtimeline.html">QTimeLine</a> uses the EaseInOut curve shape, which provides a value that grows slowly, then grows steadily, and finally grows slowly. For a custom timeline, you can reimplement <a href="qtimeline.html#valueForTime">valueForTime</a>(), in which case <a href="qtimeline.html">QTimeLine</a>'s <a href="qtimeline.html#curveShape-prop">curveShape</a> property is ignored.</p> </div> <p><b>See also </b><a href="../qtwidgets/qprogressbar.html">QProgressBar</a> and <a href="../qtwidgets/qprogressdialog.html">QProgressDialog</a>.</p> <!-- @@@QTimeLine --> <div class="types"> <h2>Member Type Documentation</h2> <!-- $$$CurveShape$$$EaseInCurve$$$EaseOutCurve$$$EaseInOutCurve$$$LinearCurve$$$SineCurve$$$CosineCurve --> <h3 class="fn" id="CurveShape-enum"><a name="CurveShape-enum"></a>enum QTimeLine::<span class="name">CurveShape</span></h3> <p>This enum describes the default shape of <a href="qtimeline.html">QTimeLine</a>'s value curve. The default, shape is EaseInOutCurve. The curve defines the relation between the value and the timeline.</p> <div class="table"><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"><code>QTimeLine::EaseInCurve</code></td><td class="topAlign tblval"><code>0</code></td><td class="topAlign">The value starts growing slowly, then increases in speed.</td></tr> <tr><td class="topAlign"><code>QTimeLine::EaseOutCurve</code></td><td class="topAlign tblval"><code>1</code></td><td class="topAlign">The value starts growing steadily, then ends slowly.</td></tr> <tr><td class="topAlign"><code>QTimeLine::EaseInOutCurve</code></td><td class="topAlign tblval"><code>2</code></td><td class="topAlign">The value starts growing slowly, then runs steadily, then grows slowly again.</td></tr> <tr><td class="topAlign"><code>QTimeLine::LinearCurve</code></td><td class="topAlign tblval"><code>3</code></td><td class="topAlign">The value grows linearly (e.g., if the duration is 1000 ms, the value at time 500 ms is 0.5).</td></tr> <tr><td class="topAlign"><code>QTimeLine::SineCurve</code></td><td class="topAlign tblval"><code>4</code></td><td class="topAlign">The value grows sinusoidally.</td></tr> <tr><td class="topAlign"><code>QTimeLine::CosineCurve</code></td><td class="topAlign tblval"><code>5</code></td><td class="topAlign">The value grows cosinusoidally.</td></tr> </table></div> <p><b>See also </b><a href="qtimeline.html#curveShape-prop">setCurveShape</a>().</p> <!-- @@@CurveShape --> <!-- $$$Direction$$$Forward$$$Backward --> <h3 class="fn" id="Direction-enum"><a name="Direction-enum"></a>enum QTimeLine::<span class="name">Direction</span></h3> <p>This enum describes the direction of the timeline when in <a href="qtimeline.html#State-enum">Running</a> state.</p> <div class="table"><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"><code>QTimeLine::Forward</code></td><td class="topAlign tblval"><code>0</code></td><td class="topAlign">The current time of the timeline increases with time (i.e., moves from 0 and towards the end / duration).</td></tr> <tr><td class="topAlign"><code>QTimeLine::Backward</code></td><td class="topAlign tblval"><code>1</code></td><td class="topAlign">The current time of the timeline decreases with time (i.e., moves from the end / duration and towards 0).</td></tr> </table></div> <p><b>See also </b><a href="qtimeline.html#direction-prop">setDirection</a>().</p> <!-- @@@Direction --> <!-- $$$State$$$NotRunning$$$Paused$$$Running --> <h3 class="fn" id="State-enum"><a name="State-enum"></a>enum QTimeLine::<span class="name">State</span></h3> <p>This enum describes the state of the timeline.</p> <div class="table"><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"><code>QTimeLine::NotRunning</code></td><td class="topAlign tblval"><code>0</code></td><td class="topAlign">The timeline is not running. This is the initial state of <a href="qtimeline.html">QTimeLine</a>, and the state <a href="qtimeline.html">QTimeLine</a> reenters when finished. The current time, frame and value remain unchanged until either <a href="qtimeline.html#currentTime-prop">setCurrentTime</a>() is called, or the timeline is started by calling <a href="qtimeline.html#start">start</a>().</td></tr> <tr><td class="topAlign"><code>QTimeLine::Paused</code></td><td class="topAlign tblval"><code>1</code></td><td class="topAlign">The timeline is paused (i.e., temporarily suspended). Calling <a href="qtimeline.html#setPaused">setPaused</a>(false) will resume timeline activity.</td></tr> <tr><td class="topAlign"><code>QTimeLine::Running</code></td><td class="topAlign tblval"><code>2</code></td><td class="topAlign">The timeline is running. While control is in the event loop, <a href="qtimeline.html">QTimeLine</a> will update its current time at regular intervals, emitting <a href="qtimeline.html#valueChanged">valueChanged</a>() and <a href="qtimeline.html#frameChanged">frameChanged</a>() when appropriate.</td></tr> </table></div> <p><b>See also </b><a href="qtimeline.html#state">state</a>() and <a href="qtimeline.html#stateChanged">stateChanged</a>().</p> <!-- @@@State --> </div> <div class="prop"> <h2>Property Documentation</h2> <!-- $$$currentTime-prop$$$currentTime$$$setCurrentTimeint --> <h3 class="fn" id="currentTime-prop"><a name="currentTime-prop"></a><span class="name">currentTime</span> : <span class="type">int</span></h3> <p>This property holds the current time of the time line.</p> <p>When <a href="qtimeline.html">QTimeLine</a> is in Running state, this value is updated continuously as a function of the duration and direction of the timeline. Otherwise, it is value that was current when <a href="qtimeline.html#stop">stop</a>() was called last, or the value set by setCurrentTime().</p> <p>By default, this property contains a value of 0.</p> <p><b>Access functions:</b></p> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft topAlign rightAlign"> int </td><td class="memItemRight bottomAlign"><span class="name"><b>currentTime</b></span>() const</td></tr> <tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setCurrentTime</b></span>(int <i>msec</i>)</td></tr> </table></div> <!-- @@@currentTime --> <!-- $$$curveShape-prop$$$curveShape$$$setCurveShapeQTimeLine::CurveShape --> <h3 class="fn" id="curveShape-prop"><a name="curveShape-prop"></a><span class="name">curveShape</span> : <span class="type"><a href="qtimeline.html#CurveShape-enum">CurveShape</a></span></h3> <p>This property holds the shape of the timeline curve.</p> <p>The curve shape describes the relation between the time and value for the base implementation of <a href="qtimeline.html#valueForTime">valueForTime</a>().</p> <p>If you have reimplemented <a href="qtimeline.html#valueForTime">valueForTime</a>(), this value is ignored.</p> <p>By default, this property is set to <a href="qtimeline.html#CurveShape-enum">EaseInOutCurve</a>.</p> <p><b>Access functions:</b></p> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft topAlign rightAlign"> QTimeLine::CurveShape </td><td class="memItemRight bottomAlign"><span class="name"><b>curveShape</b></span>() const</td></tr> <tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setCurveShape</b></span>(QTimeLine::CurveShape <i>shape</i>)</td></tr> </table></div> <p><b>See also </b><a href="qtimeline.html#valueForTime">valueForTime</a>().</p> <!-- @@@curveShape --> <!-- $$$direction-prop$$$direction$$$setDirectionQTimeLine::Direction --> <h3 class="fn" id="direction-prop"><a name="direction-prop"></a><span class="name">direction</span> : <span class="type"><a href="qtimeline.html#Direction-enum">Direction</a></span></h3> <p>This property holds the direction of the timeline when <a href="qtimeline.html">QTimeLine</a> is in <a href="qtimeline.html#State-enum">Running</a> state.</p> <p>This direction indicates whether the time moves from 0 towards the timeline duration, or from the value of the duration and towards 0 after <a href="qtimeline.html#start">start</a>() has been called.</p> <p>By default, this property is set to <a href="qtimeline.html#Direction-enum">Forward</a>.</p> <p><b>Access functions:</b></p> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft topAlign rightAlign"> QTimeLine::Direction </td><td class="memItemRight bottomAlign"><span class="name"><b>direction</b></span>() const</td></tr> <tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setDirection</b></span>(QTimeLine::Direction <i>direction</i>)</td></tr> </table></div> <!-- @@@direction --> <!-- $$$duration-prop$$$duration$$$setDurationint --> <h3 class="fn" id="duration-prop"><a name="duration-prop"></a><span class="name">duration</span> : <span class="type">int</span></h3> <p>This property holds the total duration of the timeline in milliseconds.</p> <p>By default, this value is 1000 (i.e., 1 second), but you can change this by either passing a duration to <a href="qtimeline.html">QTimeLine</a>'s constructor, or by calling setDuration(). The duration must be larger than 0.</p> <p><b>Note: </b>Changing the duration does not cause the current time to be reset to zero or the new duration. You also need to call <a href="qtimeline.html#currentTime-prop">setCurrentTime</a>() with the desired value.</p><p><b>Access functions:</b></p> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft topAlign rightAlign"> int </td><td class="memItemRight bottomAlign"><span class="name"><b>duration</b></span>() const</td></tr> <tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setDuration</b></span>(int <i>duration</i>)</td></tr> </table></div> <!-- @@@duration --> <!-- $$$easingCurve-prop$$$easingCurve$$$setEasingCurveconstQEasingCurve& --> <h3 class="fn" id="easingCurve-prop"><a name="easingCurve-prop"></a><span class="name">easingCurve</span> : <span class="type"><a href="qeasingcurve.html">QEasingCurve</a></span></h3> <p>Specifies the easing curve that the timeline will use. If both easing curve and <a href="qtimeline.html#curveShape-prop">curveShape</a> are set, the last set property will override the previous one. (If <a href="qtimeline.html#valueForTime">valueForTime</a>() is reimplemented it will override both)</p> <p>This property was introduced in Qt 4.6.</p> <p><b>Access functions:</b></p> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft topAlign rightAlign"> QEasingCurve </td><td class="memItemRight bottomAlign"><span class="name"><b>easingCurve</b></span>() const</td></tr> <tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setEasingCurve</b></span>(const QEasingCurve &<i>curve</i>)</td></tr> </table></div> <!-- @@@easingCurve --> <!-- $$$loopCount-prop$$$loopCount$$$setLoopCountint --> <h3 class="fn" id="loopCount-prop"><a name="loopCount-prop"></a><span class="name">loopCount</span> : <span class="type">int</span></h3> <p>This property holds the number of times the timeline should loop before it's finished.</p> <p>A loop count of of 0 means that the timeline will loop forever.</p> <p>By default, this property contains a value of 1.</p> <p><b>Access functions:</b></p> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft topAlign rightAlign"> int </td><td class="memItemRight bottomAlign"><span class="name"><b>loopCount</b></span>() const</td></tr> <tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setLoopCount</b></span>(int <i>count</i>)</td></tr> </table></div> <!-- @@@loopCount --> <!-- $$$updateInterval-prop$$$updateInterval$$$setUpdateIntervalint --> <h3 class="fn" id="updateInterval-prop"><a name="updateInterval-prop"></a><span class="name">updateInterval</span> : <span class="type">int</span></h3> <p>This property holds the time in milliseconds between each time <a href="qtimeline.html">QTimeLine</a> updates its current time.</p> <p>When updating the current time, <a href="qtimeline.html">QTimeLine</a> will emit <a href="qtimeline.html#valueChanged">valueChanged</a>() if the current value changed, and <a href="qtimeline.html#frameChanged">frameChanged</a>() if the frame changed.</p> <p>By default, the interval is 40 ms, which corresponds to a rate of 25 updates per second.</p> <p><b>Access functions:</b></p> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft topAlign rightAlign"> int </td><td class="memItemRight bottomAlign"><span class="name"><b>updateInterval</b></span>() const</td></tr> <tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setUpdateInterval</b></span>(int <i>interval</i>)</td></tr> </table></div> <!-- @@@updateInterval --> </div> <div class="func"> <h2>Member Function Documentation</h2> <!-- $$$QTimeLine[overload1]$$$QTimeLineintQObject* --> <h3 class="fn" id="QTimeLine"><a name="QTimeLine"></a>QTimeLine::<span class="name">QTimeLine</span>(<span class="type">int</span> <i>duration</i> = 1000, <span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>parent</i> = nullptr)</h3> <p>Constructs a timeline with a duration of <i>duration</i> milliseconds. <i>parent</i> is passed to <a href="qobject.html">QObject</a>'s constructor. The default duration is 1000 milliseconds.</p> <!-- @@@QTimeLine --> <!-- $$$~QTimeLine[overload1]$$$~QTimeLine --> <h3 class="fn" id="dtor.QTimeLine"><a name="dtor.QTimeLine"></a><code>[virtual] </code>QTimeLine::<span class="name">~QTimeLine</span>()</h3> <p>Destroys the timeline.</p> <!-- @@@~QTimeLine --> <!-- $$$currentFrame[overload1]$$$currentFrame --> <h3 class="fn" id="currentFrame"><a name="currentFrame"></a><span class="type">int</span> QTimeLine::<span class="name">currentFrame</span>() const</h3> <p>Returns the frame corresponding to the current time.</p> <p><b>See also </b><a href="qtimeline.html#currentTime-prop">currentTime</a>(), <a href="qtimeline.html#frameForTime">frameForTime</a>(), and <a href="qtimeline.html#setFrameRange">setFrameRange</a>().</p> <!-- @@@currentFrame --> <!-- $$$currentValue[overload1]$$$currentValue --> <h3 class="fn" id="currentValue"><a name="currentValue"></a><span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> QTimeLine::<span class="name">currentValue</span>() const</h3> <p>Returns the value corresponding to the current time.</p> <p><b>See also </b><a href="qtimeline.html#valueForTime">valueForTime</a>() and <a href="qtimeline.html#currentFrame">currentFrame</a>().</p> <!-- @@@currentValue --> <!-- $$$endFrame[overload1]$$$endFrame --> <h3 class="fn" id="endFrame"><a name="endFrame"></a><span class="type">int</span> QTimeLine::<span class="name">endFrame</span>() const</h3> <p>Returns the end frame, which is the frame corresponding to the end of the timeline (i.e., the frame for which the current value is 1).</p> <p><b>See also </b><a href="qtimeline.html#setEndFrame">setEndFrame</a>() and <a href="qtimeline.html#setFrameRange">setFrameRange</a>().</p> <!-- @@@endFrame --> <!-- $$$finished[overload1]$$$finished --> <h3 class="fn" id="finished"><a name="finished"></a><code>[signal] </code><span class="type">void</span> QTimeLine::<span class="name">finished</span>()</h3> <p>This signal is emitted when <a href="qtimeline.html">QTimeLine</a> finishes (i.e., reaches the end of its time line), and does not loop.</p> <p><b>Note: </b>This is a private signal. It can be used in signal connections but cannot be emitted by the user.</p> <!-- @@@finished --> <!-- $$$frameChanged[overload1]$$$frameChangedint --> <h3 class="fn" id="frameChanged"><a name="frameChanged"></a><code>[signal] </code><span class="type">void</span> QTimeLine::<span class="name">frameChanged</span>(<span class="type">int</span> <i>frame</i>)</h3> <p><a href="qtimeline.html">QTimeLine</a> emits this signal at regular intervals when in <a href="qtimeline.html#State-enum">Running</a> state, but only if the current frame changes. <i>frame</i> is the current frame number.</p> <p><b>Note: </b>This is a private signal. It can be used in signal connections but cannot be emitted by the user.</p> <p><b>See also </b><a href="qtimeline.html#setFrameRange">QTimeLine::setFrameRange</a>() and <a href="qtimeline.html#updateInterval-prop">QTimeLine::updateInterval</a>.</p> <!-- @@@frameChanged --> <!-- $$$frameForTime[overload1]$$$frameForTimeint --> <h3 class="fn" id="frameForTime"><a name="frameForTime"></a><span class="type">int</span> QTimeLine::<span class="name">frameForTime</span>(<span class="type">int</span> <i>msec</i>) const</h3> <p>Returns the frame corresponding to the time <i>msec</i>. This value is calculated using a linear interpolation of the start and end frame, based on the value returned by <a href="qtimeline.html#valueForTime">valueForTime</a>().</p> <p><b>See also </b><a href="qtimeline.html#valueForTime">valueForTime</a>() and <a href="qtimeline.html#setFrameRange">setFrameRange</a>().</p> <!-- @@@frameForTime --> <!-- $$$resume[overload1]$$$resume --> <h3 class="fn" id="resume"><a name="resume"></a><code>[slot] </code><span class="type">void</span> QTimeLine::<span class="name">resume</span>()</h3> <p>Resumes the timeline from the current time. <a href="qtimeline.html">QTimeLine</a> will reenter Running state, and once it enters the event loop, it will update its current time, frame and value at regular intervals.</p> <p>In contrast to <a href="qtimeline.html#start">start</a>(), this function does not restart the timeline before it resumes.</p> <p><b>See also </b><a href="qtimeline.html#start">start</a>(), <a href="qtimeline.html#updateInterval-prop">updateInterval</a>(), <a href="qtimeline.html#frameChanged">frameChanged</a>(), and <a href="qtimeline.html#valueChanged">valueChanged</a>().</p> <!-- @@@resume --> <!-- $$$setEndFrame[overload1]$$$setEndFrameint --> <h3 class="fn" id="setEndFrame"><a name="setEndFrame"></a><span class="type">void</span> QTimeLine::<span class="name">setEndFrame</span>(<span class="type">int</span> <i>frame</i>)</h3> <p>Sets the end frame, which is the frame corresponding to the end of the timeline (i.e., the frame for which the current value is 1), to <i>frame</i>.</p> <p><b>See also </b><a href="qtimeline.html#endFrame">endFrame</a>(), <a href="qtimeline.html#startFrame">startFrame</a>(), and <a href="qtimeline.html#setFrameRange">setFrameRange</a>().</p> <!-- @@@setEndFrame --> <!-- $$$setFrameRange[overload1]$$$setFrameRangeintint --> <h3 class="fn" id="setFrameRange"><a name="setFrameRange"></a><span class="type">void</span> QTimeLine::<span class="name">setFrameRange</span>(<span class="type">int</span> <i>startFrame</i>, <span class="type">int</span> <i>endFrame</i>)</h3> <p>Sets the timeline's frame counter to start at <i>startFrame</i>, and end and <i>endFrame</i>. For each time value, <a href="qtimeline.html">QTimeLine</a> will find the corresponding frame when you call <a href="qtimeline.html#currentFrame">currentFrame</a>() or <a href="qtimeline.html#frameForTime">frameForTime</a>() by interpolating, using the return value of <a href="qtimeline.html#valueForTime">valueForTime</a>().</p> <p>When in Running state, <a href="qtimeline.html">QTimeLine</a> also emits the <a href="qtimeline.html#frameChanged">frameChanged</a>() signal when the frame changes.</p> <p><b>See also </b><a href="qtimeline.html#startFrame">startFrame</a>(), <a href="qtimeline.html#endFrame">endFrame</a>(), <a href="qtimeline.html#start">start</a>(), and <a href="qtimeline.html#currentFrame">currentFrame</a>().</p> <!-- @@@setFrameRange --> <!-- $$$setPaused[overload1]$$$setPausedbool --> <h3 class="fn" id="setPaused"><a name="setPaused"></a><code>[slot] </code><span class="type">void</span> QTimeLine::<span class="name">setPaused</span>(<span class="type">bool</span> <i>paused</i>)</h3> <p>If <i>paused</i> is true, the timeline is paused, causing <a href="qtimeline.html">QTimeLine</a> to enter Paused state. No updates will be signaled until either <a href="qtimeline.html#start">start</a>() or setPaused(false) is called. If <i>paused</i> is false, the timeline is resumed and continues where it left.</p> <p><b>See also </b><a href="qtimeline.html#state">state</a>() and <a href="qtimeline.html#start">start</a>().</p> <!-- @@@setPaused --> <!-- $$$setStartFrame[overload1]$$$setStartFrameint --> <h3 class="fn" id="setStartFrame"><a name="setStartFrame"></a><span class="type">void</span> QTimeLine::<span class="name">setStartFrame</span>(<span class="type">int</span> <i>frame</i>)</h3> <p>Sets the start frame, which is the frame corresponding to the start of the timeline (i.e., the frame for which the current value is 0), to <i>frame</i>.</p> <p><b>See also </b><a href="qtimeline.html#startFrame">startFrame</a>(), <a href="qtimeline.html#endFrame">endFrame</a>(), and <a href="qtimeline.html#setFrameRange">setFrameRange</a>().</p> <!-- @@@setStartFrame --> <!-- $$$start[overload1]$$$start --> <h3 class="fn" id="start"><a name="start"></a><code>[slot] </code><span class="type">void</span> QTimeLine::<span class="name">start</span>()</h3> <p>Starts the timeline. <a href="qtimeline.html">QTimeLine</a> will enter Running state, and once it enters the event loop, it will update its current time, frame and value at regular intervals. The default interval is 40 ms (i.e., 25 times per second). You can change the update interval by calling <a href="qtimeline.html#updateInterval-prop">setUpdateInterval</a>().</p> <p>The timeline will start from position 0, or the end if going backward. If you want to resume a stopped timeline without restarting, you can call <a href="qtimeline.html#resume">resume</a>() instead.</p> <p><b>See also </b><a href="qtimeline.html#resume">resume</a>(), <a href="qtimeline.html#updateInterval-prop">updateInterval</a>(), <a href="qtimeline.html#frameChanged">frameChanged</a>(), and <a href="qtimeline.html#valueChanged">valueChanged</a>().</p> <!-- @@@start --> <!-- $$$startFrame[overload1]$$$startFrame --> <h3 class="fn" id="startFrame"><a name="startFrame"></a><span class="type">int</span> QTimeLine::<span class="name">startFrame</span>() const</h3> <p>Returns the start frame, which is the frame corresponding to the start of the timeline (i.e., the frame for which the current value is 0).</p> <p><b>See also </b><a href="qtimeline.html#setStartFrame">setStartFrame</a>() and <a href="qtimeline.html#setFrameRange">setFrameRange</a>().</p> <!-- @@@startFrame --> <!-- $$$state[overload1]$$$state --> <h3 class="fn" id="state"><a name="state"></a><span class="type"><a href="qtimeline.html#State-enum">QTimeLine::State</a></span> QTimeLine::<span class="name">state</span>() const</h3> <p>Returns the state of the timeline.</p> <p><b>See also </b><a href="qtimeline.html#start">start</a>(), <a href="qtimeline.html#setPaused">setPaused</a>(), and <a href="qtimeline.html#stop">stop</a>().</p> <!-- @@@state --> <!-- $$$stateChanged[overload1]$$$stateChangedQTimeLine::State --> <h3 class="fn" id="stateChanged"><a name="stateChanged"></a><code>[signal] </code><span class="type">void</span> QTimeLine::<span class="name">stateChanged</span>(<span class="type"><a href="qtimeline.html#State-enum">QTimeLine::State</a></span> <i>newState</i>)</h3> <p>This signal is emitted whenever <a href="qtimeline.html">QTimeLine</a>'s state changes. The new state is <i>newState</i>.</p> <p><b>Note: </b>This is a private signal. It can be used in signal connections but cannot be emitted by the user.</p> <!-- @@@stateChanged --> <!-- $$$stop[overload1]$$$stop --> <h3 class="fn" id="stop"><a name="stop"></a><code>[slot] </code><span class="type">void</span> QTimeLine::<span class="name">stop</span>()</h3> <p>Stops the timeline, causing <a href="qtimeline.html">QTimeLine</a> to enter <a href="qtimeline.html#State-enum">NotRunning</a> state.</p> <p><b>See also </b><a href="qtimeline.html#start">start</a>().</p> <!-- @@@stop --> <!-- $$$timerEvent[overload1]$$$timerEventQTimerEvent* --> <h3 class="fn" id="timerEvent"><a name="timerEvent"></a><code>[override virtual protected] </code><span class="type">void</span> QTimeLine::<span class="name">timerEvent</span>(<span class="type"><a href="qtimerevent.html">QTimerEvent</a></span> *<i>event</i>)</h3> <p>Reimplemented from <a href="qobject.html#timerEvent">QObject::timerEvent</a>().</p> <!-- @@@timerEvent --> <!-- $$$toggleDirection[overload1]$$$toggleDirection --> <h3 class="fn" id="toggleDirection"><a name="toggleDirection"></a><code>[slot] </code><span class="type">void</span> QTimeLine::<span class="name">toggleDirection</span>()</h3> <p>Toggles the direction of the timeline. If the direction was Forward, it becomes Backward, and vice verca.</p> <p><b>See also </b><a href="qtimeline.html#direction-prop">setDirection</a>().</p> <!-- @@@toggleDirection --> <!-- $$$valueChanged[overload1]$$$valueChangedqreal --> <h3 class="fn" id="valueChanged"><a name="valueChanged"></a><code>[signal] </code><span class="type">void</span> QTimeLine::<span class="name">valueChanged</span>(<span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> <i>value</i>)</h3> <p><a href="qtimeline.html">QTimeLine</a> emits this signal at regular intervals when in <a href="qtimeline.html#State-enum">Running</a> state, but only if the current value changes. <i>value</i> is the current value. <i>value</i> is a number between 0.0 and 1.0</p> <p><b>Note: </b>This is a private signal. It can be used in signal connections but cannot be emitted by the user.</p> <p><b>See also </b><a href="qtimeline.html#duration-prop">QTimeLine::setDuration</a>(), <a href="qtimeline.html#valueForTime">QTimeLine::valueForTime</a>(), and <a href="qtimeline.html#updateInterval-prop">QTimeLine::updateInterval</a>.</p> <!-- @@@valueChanged --> <!-- $$$valueForTime[overload1]$$$valueForTimeint --> <h3 class="fn" id="valueForTime"><a name="valueForTime"></a><code>[virtual] </code><span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> QTimeLine::<span class="name">valueForTime</span>(<span class="type">int</span> <i>msec</i>) const</h3> <p>Returns the timeline value for the time <i>msec</i>. The returned value, which varies depending on the curve shape, is always between 0 and 1. If <i>msec</i> is 0, the default implementation always returns 0.</p> <p>Reimplement this function to provide a custom curve shape for your timeline.</p> <p><b>See also </b><a href="qtimeline.html#CurveShape-enum">CurveShape</a> and <a href="qtimeline.html#frameForTime">frameForTime</a>().</p> <!-- @@@valueForTime --> </div> </div> </div> </div> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2019 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>