NumberAnimation Element Reference

The NumberAnimation element animates changes in qreal-type values.

[Inherits PropertyAnimation]

Inherited by SmoothedAnimation and SpringAnimation.

This element was introduced in Qt 4.7.

Detailed Description

The NumberAnimation element animates changes in qreal-type values.

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:

  1. import QtQuick 1.0
  2.  
  3. Rectangle  {
  4.     width: 100; height: 100
  5.     color: "red"
  6.  
  7.     NumberAnimation on x  { to: 50; duration: 1000 }
  8. }

Like any other animation element, a NumberAnimation can be applied in a number of ways, including transitions, behaviors and property value sources. The QML Animation and Transitions 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.

Properties

Property Documentation

This property holds the starting value for the animation.

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

  1.                 Item  {
  2.     states: [
  3.         // ...
  4.     ]
  5.  
  6.     transition: Transition  {
  7.         NumberAnimation  { properties: "x"; from: 100; duration: 200 }
  8.     }
  9. }

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 QML Animation and Transitions.

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 QML Animation and Transitions.

Notes provided by the Qt Community

No notes