
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheParentAnimation element animates changes in parent values.More...
| Since: | Qt 4.7 |
| Inherits: |
ParentAnimation is used to animate a parent change for anItem.
For example, the followingParentChange changesblueRect to become a child ofredRect when it is clicked. The inclusion of theParentAnimation, which defines aNumberAnimation to be applied during the transition, ensures the item animates smoothly as it moves to its new parent:
import QtQuick 1.0Item {width:200;height:100Rectangle {id:redRectwidth:100;height:100color:"red" }Rectangle {id:blueRectx:redRect.widthwidth:50;height:50color:"blue"states:State {name:"reparented"ParentChange {target:blueRect;parent:redRect;x:10;y:10 } }transitions:Transition {ParentAnimation {NumberAnimation {properties:"x,y";duration:1000 } } }MouseArea {anchors.fill:parent;onClicked:blueRect.state="reparented" } }}
AParentAnimation can contain any number of animations. These animations will be run in parallel; to run them sequentially, define them within aSequentialAnimation.
In some cases, such as when reparenting between items with clipping enabled, it is useful to animate the parent change via another item that does not have clipping enabled. Such an item can be set using thevia property.
For convenience, when aParentAnimation is used in aTransition, it will animate anyParentChange that has occurred during the state change. This can be overridden by setting a specific target item using thetarget property.
Like any other animation element, aParentAnimation can be applied in a number of ways, including transitions, behaviors and property value sources. TheQML Animation and Transitions documentation shows a variety of methods for creating animations.
See alsoQML Animation and Transitions and Animation basics example.
newParent :Item |
The new parent to animate to.
If theParentAnimation is defined within aTransition orBehavior, this value defaults to the value defined in the end state of theTransition, or the value of the property change that triggered theBehavior.
target :Item |
The item to reparent.
When used in a transition, if no target is specified, allParentChange occurrences are animated by theParentAnimation.
via :Item |
The item to reparent via. This provides a way to do an unclipped animation when both the old parent and new parent are clipped.
ParentAnimation {target:myItemvia:topLevelItem// ...}
© 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.