Qt 4.8
Behavior Class Reference

The Behavior element allows you to specify a default animation for a property change. More...

Detailed Description

The Behavior element allows you to specify a default animation for a property change.

Since
4.7

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 1.0
Rectangle {
id: rect
width: 100; height: 100
color: "red"
Behavior on width {
NumberAnimation { duration: 1000 }
}
MouseArea {
anchors.fill: parent
onClicked: rect.width = 50
}
}

Note that a property cannot have more than one assigned Behavior. To provide multiple animations within a Behavior, use ParallelAnimation or SequentialAnimation.

If a QML States{state change} has a Transition that matches the same property as a Behavior, the Transition animation overrides the Behavior for that state change. For general advice on using Behaviors to animate state changes, see Using QML Behaviors with States.

See also
{QML Animation and Transitions}, {declarative/animation/behaviors}{Behavior example}, QtDeclarative

The documentation for this class was generated from the following file: