NumberAnimation QML Type

Animates changes in qreal-type values. More...

Import Statement: import QtQuick
Inherits:

PropertyAnimation

Inherited By:

SmoothedAnimation and SpringAnimation

Properties

Detailed Description

NumberAnimation is a specialized PropertyAnimation that defines an animation to be applied when a numerical value changes.

Here is a NumberAnimation applied to the x property of a Rectangle as a property value source. It animates the x value from its current value to a value of 50, over 1000 milliseconds:

import QtQuick 2.0

Rectangle {
    width: 100; height: 100
    color: "red"

    NumberAnimation on x { to: 50; duration: 1000 }
}

Like any other animation type, a NumberAnimation can be applied in a number of ways, including transitions, behaviors and property value sources. The Animation and Transitions in Qt Quick documentation shows a variety of methods for creating animations.

Note that NumberAnimation may not animate smoothly if there are irregular changes in the number value that it is tracking. If this is the case, use SmoothedAnimation instead.

See also Animation and Transitions in Qt Quick and Qt Quick Examples - Animation.

Property Documentation

from : real

This property holds the starting value for the animation.

For example, the following animation is not applied until the x value has reached 100:

Item {
    states: [
        // ...
    ]

    transitions: Transition {
        NumberAnimation { properties: "x"; from: 100; duration: 200 }
    }
}

If the NumberAnimation is defined within a Transition or Behavior, this value defaults to the value defined in the starting state of the Transition, or the current value of the property at the moment the Behavior is triggered.

See also Animation and Transitions in Qt Quick.


to : real

This property holds the end value for the animation.

If the NumberAnimation is defined within a Transition or Behavior, this value defaults to the value defined in the end state of the Transition, or the value of the property change that triggered the Behavior.

See also Animation and Transitions in Qt Quick.


© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. 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.