
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
The Behavior element allows you to specify a default animation for a property change.More...
| Since: | Qt 4.7 |
A Behavior defines the default animation to be applied whenever a particular property value changes.
For example, the following Behavior defines aNumberAnimation to be run whenever theRectangle'swidth value changes. When theMouseArea is clicked, thewidth is changed, triggering the behavior's animation:
import QtQuick 1.0Rectangle {id:rectwidth:100;height:100color:"red" Behavior onwidth {NumberAnimation {duration:1000 } }MouseArea {anchors.fill:parentonClicked:rect.width=50 }}
Note that a property cannot have more than one assigned Behavior. To provide multiple animations within a Behavior, useParallelAnimation orSequentialAnimation.
If astate change has aTransition that matches the same property as a Behavior, theTransition animation overrides the Behavior for that state change. For general advice on using Behaviors to animate state changes, seeUsing QML Behaviors with States.
See alsoQML Animation and Transitions, Behavior example, andQtDeclarative.
defaultanimation :Animation |
This property holds the animation to run when the behavior is triggered.
This property holds whether the behavior will be triggered when the tracked property changes value.
By default a Behavior is enabled.
© 2016 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 theGNU 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.