<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- qquicksmoothedanimation.cpp --> <title>SmoothedAnimation QML Type | Qt Quick 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="qtquick-index.html">Qt Quick</a></td><td ><a href="qtquick-qmlmodule.html">QML Types</a></td><td >SmoothedAnimation QML Type</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="#properties">Properties</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">SmoothedAnimation QML Type</h1> <span class="subtitle"></span> <!-- $$$SmoothedAnimation-brief --> <p>Allows a property to smoothly track a value <a href="#details">More...</a></p> <!-- @@@SmoothedAnimation --> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> Import Statement:</td><td class="memItemRight bottomAlign"> import QtQuick 2.7</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherits:</td><td class="memItemRight bottomAlign"> <p><a href="qml-qtquick-numberanimation.html">NumberAnimation</a></p> </td></tr></table></div><ul> <li><a href="qml-qtquick-smoothedanimation-members.html">List of all members, including inherited members</a></li> </ul> <a name="properties"></a> <h2 id="properties">Properties</h2> <ul> <li class="fn"><b><b><a href="qml-qtquick-smoothedanimation.html#duration-prop">duration</a></b></b> : int</li> <li class="fn"><b><b><a href="qml-qtquick-smoothedanimation.html#maximumEasingTime-prop">maximumEasingTime</a></b></b> : int</li> <li class="fn"><b><b><a href="qml-qtquick-smoothedanimation.html#reversingMode-prop">reversingMode</a></b></b> : enumeration</li> <li class="fn"><b><b><a href="qml-qtquick-smoothedanimation.html#velocity-prop">velocity</a></b></b> : real</li> </ul> <!-- $$$SmoothedAnimation-description --> <a name="details"></a> <h2 id="details">Detailed Description</h2> <p>A <a href="qml-qtquick-smoothedanimation.html">SmoothedAnimation</a> animates a property's value to a set target value using an ease in/out quad easing curve. When the target value changes, the easing curves used to animate between the old and new target values are smoothly spliced together to create a smooth movement to the new target value that maintains the current velocity.</p> <p>The follow example shows one <a href="qml-qtquick-rectangle.html">Rectangle</a> tracking the position of another using <a href="qml-qtquick-smoothedanimation.html">SmoothedAnimation</a>. The green rectangle's <code>x</code> and <code>y</code> values are bound to those of the red rectangle. Whenever these values change, the green rectangle smoothly animates to its new position:</p> <pre class="qml"> import QtQuick 2.0 <span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> { <span class="name">width</span>: <span class="number">800</span>; <span class="name">height</span>: <span class="number">600</span> <span class="name">color</span>: <span class="string">"blue"</span> <span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> { <span class="name">width</span>: <span class="number">60</span>; <span class="name">height</span>: <span class="number">60</span> <span class="name">x</span>: <span class="name">rect1</span>.<span class="name">x</span> <span class="operator">-</span> <span class="number">5</span>; <span class="name">y</span>: <span class="name">rect1</span>.<span class="name">y</span> <span class="operator">-</span> <span class="number">5</span> <span class="name">color</span>: <span class="string">"green"</span> Behavior on <span class="name">x</span> { <span class="type"><a href="qml-qtquick-smoothedanimation.html">SmoothedAnimation</a></span> { <span class="name">velocity</span>: <span class="number">200</span> } } Behavior on <span class="name">y</span> { <span class="type"><a href="qml-qtquick-smoothedanimation.html">SmoothedAnimation</a></span> { <span class="name">velocity</span>: <span class="number">200</span> } } } <span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> { <span class="name">id</span>: <span class="name">rect1</span> <span class="name">width</span>: <span class="number">50</span>; <span class="name">height</span>: <span class="number">50</span> <span class="name">color</span>: <span class="string">"red"</span> } <span class="name">focus</span>: <span class="number">true</span> <span class="name">Keys</span>.onRightPressed: <span class="name">rect1</span>.<span class="name">x</span> <span class="operator">=</span> <span class="name">rect1</span>.<span class="name">x</span> <span class="operator">+</span> <span class="number">100</span> <span class="name">Keys</span>.onLeftPressed: <span class="name">rect1</span>.<span class="name">x</span> <span class="operator">=</span> <span class="name">rect1</span>.<span class="name">x</span> <span class="operator">-</span> <span class="number">100</span> <span class="name">Keys</span>.onUpPressed: <span class="name">rect1</span>.<span class="name">y</span> <span class="operator">=</span> <span class="name">rect1</span>.<span class="name">y</span> <span class="operator">-</span> <span class="number">100</span> <span class="name">Keys</span>.onDownPressed: <span class="name">rect1</span>.<span class="name">y</span> <span class="operator">=</span> <span class="name">rect1</span>.<span class="name">y</span> <span class="operator">+</span> <span class="number">100</span> } </pre> <p>A <a href="qml-qtquick-smoothedanimation.html">SmoothedAnimation</a> can be configured by setting the <a href="qml-qtquick-smoothedanimation.html#velocity-prop">velocity</a> at which the animation should occur, or the <a href="qml-qtquick-smoothedanimation.html#duration-prop">duration</a> that the animation should take. If both the <a href="qml-qtquick-smoothedanimation.html#velocity-prop">velocity</a> and <a href="qml-qtquick-smoothedanimation.html#duration-prop">duration</a> are specified, the one that results in the quickest animation is chosen for each change in the target value.</p> <p>For example, animating from 0 to 800 will take 4 seconds if a velocity of 200 is set, will take 8 seconds with a duration of 8000 set, and will take 4 seconds with both a velocity of 200 and a duration of 8000 set. Animating from 0 to 20000 will take 10 seconds if a velocity of 200 is set, will take 8 seconds with a duration of 8000 set, and will take 8 seconds with both a velocity of 200 and a duration of 8000 set.</p> <p>The default velocity of <a href="qml-qtquick-smoothedanimation.html">SmoothedAnimation</a> is 200 units/second. Note that if the range of the value being animated is small, then the velocity will need to be adjusted appropriately. For example, the opacity of an item ranges from 0 - 1.0. To enable a smooth animation in this range the velocity will need to be set to a value such as 0.5 units/second. Animating from 0 to 1.0 with a velocity of 0.5 will take 2000 ms to complete.</p> <p>Like any other animation type, a <a href="qml-qtquick-smoothedanimation.html">SmoothedAnimation</a> can be applied in a number of ways, including transitions, behaviors and property value sources. The <a href="qtquick-statesanimations-animations.html">Animation and Transitions in Qt Quick</a> documentation shows a variety of methods for creating animations.</p> <p><b>See also </b><a href="qml-qtquick-springanimation.html">SpringAnimation</a>, <a href="qml-qtquick-numberanimation.html">NumberAnimation</a>, <a href="qtquick-statesanimations-animations.html">Animation and Transitions in Qt Quick</a>, and <a href="qtquick-animation-example.html">Qt Quick Examples - Animation</a>.</p> <!-- @@@SmoothedAnimation --> <h2>Property Documentation</h2> <!-- $$$duration --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="duration-prop"> <td class="tblQmlPropNode"><p> <a name="duration-prop"></a><span class="name">duration</span> : <span class="type">int</span></p></td></tr> </table></div> </div><div class="qmldoc"><p>This property holds the animation duration, in msecs, used when tracking the source.</p> <p>Setting this to -1 (the default) disables the duration value.</p> <p>If the velocity value and the duration value are both enabled, then the animation will use whichever gives the shorter duration.</p> </div></div><!-- @@@duration --> <br/> <!-- $$$maximumEasingTime --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="maximumEasingTime-prop"> <td class="tblQmlPropNode"><p> <a name="maximumEasingTime-prop"></a><span class="name">maximumEasingTime</span> : <span class="type">int</span></p></td></tr> </table></div> </div><div class="qmldoc"><p>This property specifies the maximum time, in msecs, any "eases" during the follow should take. Setting this property causes the velocity to "level out" after at a time. Setting a negative value reverts to the normal mode of easing over the entire animation duration.</p> <p>The default value is -1.</p> </div></div><!-- @@@maximumEasingTime --> <br/> <!-- $$$reversingMode --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="reversingMode-prop"> <td class="tblQmlPropNode"><p> <a name="reversingMode-prop"></a><span class="name">reversingMode</span> : <span class="type">enumeration</span></p></td></tr> </table></div> </div><div class="qmldoc"><p>Sets how the <a href="qml-qtquick-smoothedanimation.html">SmoothedAnimation</a> behaves if an animation direction is reversed.</p> <p>Possible values are:</p> <ul> <li><a href="qml-qtquick-smoothedanimation.html">SmoothedAnimation</a>.Eased (default) - the animation will smoothly decelerate, and then reverse direction</li> <li><a href="qml-qtquick-smoothedanimation.html">SmoothedAnimation</a>.Immediate - the animation will immediately begin accelerating in the reverse direction, beginning with a velocity of 0</li> <li><a href="qml-qtquick-smoothedanimation.html">SmoothedAnimation</a>.Sync - the property is immediately set to the target value</li> </ul> </div></div><!-- @@@reversingMode --> <br/> <!-- $$$velocity --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="velocity-prop"> <td class="tblQmlPropNode"><p> <a name="velocity-prop"></a><span class="name">velocity</span> : <span class="type">real</span></p></td></tr> </table></div> </div><div class="qmldoc"><p>This property holds the average velocity allowed when tracking the 'to' value.</p> <p>The default velocity of <a href="qml-qtquick-smoothedanimation.html">SmoothedAnimation</a> is 200 units/second.</p> <p>Setting this to -1 disables the velocity value.</p> <p>If the velocity value and the duration value are both enabled, then the animation will use whichever gives the shorter duration.</p> </div></div><!-- @@@velocity --> <br/> </div> </div> </div> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</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>