Animation QML Type

Is the base of all QML animations. 更多...

导入语句: import QtQuick .
Since: Qt Quick Ultralite 1.0
继承者:

ParallelAnimation , PauseAnimation , PropertyAnimation , ScriptAction ,和 SequentialAnimation

特性

信号

方法

详细描述

The Animation type cannot be used directly in a QML file. It exists to provide a set of common properties and methods, available across all the other animation types that inherit from it. Attempting to use the Animation type directly will result in an error.

另请参阅 Important Concepts in Qt Quick Ultralite - States, Transitions and Animations .

特性文档编制

alwaysRunToEnd : bool

This property holds whether the animation should run to completion when it is stopped.

If this true the animation will complete its current iteration when it is stopped - either by setting the running property to false, or by calling the stop() method. The complete() method is not effected by this value.

This behavior is most useful when the loops property is set, as the animation will finish playing normally but not restart.

By default, the alwaysRunToEnd property is not set.

注意: alwaysRunToEnd has no effect on animations in a Transition.


loops : int

This property holds the number of times the animation should play.

默认情况下, loops is 1: the animation will play through once and then stop.

If set to Animation.Infinite or negative value, the animation will continuously repeat until it is explicitly stopped - either by setting the running property to false, or by calling the stop() 方法。

In the following example, the rectangle will spin indefinitely.

Rectangle {
    width: 100; height: 100; color: "green"
    RotationAnimation on rotation {
        loops: Animation.Infinite
        from: 0
        to: 360
    }
}
								

running : bool

This property holds whether the animation is currently running.

running property can be set to declaratively control whether or not an animation is running. The following example will animate a rectangle whenever the MouseArea is pressed.

Rectangle {
    width: 100; height: 100
    NumberAnimation on x {
        running: myMouse.pressed
        from: 0; to: 100
    }
    MouseArea { id: myMouse }
}
								

Likewise, the running property can be read to determine if the animation is running. In the following example the Text item will indicate whether or not the animation is running.

NumberAnimation { id: myAnimation }
Text { text: myAnimation.running ? "Animation is running" : "Animation is not running" }
								

Animations can also be started and stopped imperatively from JavaScript using the start() and stop() 方法。

By default, animations are not running. Though, when the animations are assigned to properties, as property value sources using the on syntax, they are set to running by default.


信号文档编制

finished ()

This signal is emitted when the animation has finished naturally.

It is not emitted when running 被设为 false , nor for animations whose loops property is set to Animation.Infinite .

In addition, it is only emitted for top-level, standalone animations. It will not be emitted for animations in a Behavior or Transition, or animations that are part of an animation group.

alwaysRunToEnd is true, this signal will not be emitted until the animation has completed its current iteration.

相应处理程序是 onFinished .

注意: 相应处理程序是 onFinished .

This signal was introduced in Qt Quick Ultralite 1.1.

另请参阅 stopped() , started() ,和 running .


started ()

This signal is emitted when the animation begins.

It is only triggered for top-level, standalone animations. It will not be triggered for animations in a Behavior or Transition, or animations that are part of an animation group.

相应处理程序是 onStarted .

注意: 相应处理程序是 onStarted .

This signal was introduced in Qt Quick Ultralite 1.1.


stopped ()

This signal is emitted when the animation ends.

The animation may have been stopped manually, or may have run to completion.

It is only triggered for top-level, standalone animations. It will not be triggered for animations in a Behavior or Transition, or animations that are part of an animation group.

alwaysRunToEnd is true, this signal will not be emitted until the animation has completed its current iteration.

相应处理程序是 onStopped .

注意: 相应处理程序是 onStopped .

This signal was introduced in Qt Quick Ultralite 1.1.


方法文档编制

start ()

Starts the animation

If the animation is already running, calling this method has no effect. The running property will be true following a call to start() .


stop ()

Stops the animation

If the animation is not running, calling this method has no effect. Both the running and paused properties will be false following a call to stop() .

Normally stop() stops the animation immediately, and the animation has no further influence on property values. In this example animation

Rectangle {
    NumberAnimation on x { from: 0; to: 100; duration: 500 }
}
								

was stopped at time 250ms, the x property will have a value of 50.

However, if the alwaysRunToEnd property is set, the animation will continue running until it completes and then stop. The running property will still become false immediately.