Defines a default animation for a property change. 更多...
导入语句: | import QtQuick . |
Since: | Qt Quick Ultralite 1.0 |
A Behavior defines the default animation to be applied whenever a particular property value changes.
For example, the following Behavior defines a
NumberAnimation
to be run whenever the
Rectangle
's
width
value changes. When the
MouseArea
is clicked, the
width
is changed, triggering the behavior's animation:
import QtQuick 2.15 Rectangle { id: rect width: 100; height: 100 color: "red" Behavior on width { NumberAnimation { duration: 1000 } } MouseArea { anchors.fill: parent onClicked: rect.width = 50 } }
注意: A property cannot have more than one assigned Behavior. To provide multiple animations within a Behavior, use ParallelAnimation or SequentialAnimation .
若 state change has a Transition that matches the same property as a Behavior, the Transition animation overrides the Behavior for that state change.
另请参阅 动画和过渡 .
enabled : bool |
This property holds whether the behavior is triggered when the tracked property changes value.
By default a Behavior is enabled.