QML ParentAnimation ElementThe ParentAnimation element animates changes in parent values. More... Inherits Animation This element was introduced in Qt 4.7. PropertiesDetailed DescriptionParentAnimation is used to animate a parent change for an Item. For example, the following ParentChange changes blueRect to become a child of redRect when it is clicked. The inclusion of the ParentAnimation, which defines a NumberAnimation to be applied during the transition, ensures the item animates smoothly as it moves to its new parent: import QtQuick 1.0 Item { width: 200; height: 100 Rectangle { id: redRect width: 100; height: 100 color: "red" } Rectangle { id: blueRect x: redRect.width width: 50; height: 50 color: "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" } } } A ParentAnimation can contain any number of animations. These animations will be run in parallel; to run them sequentially, define them within a SequentialAnimation. 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 the via property. For convenience, when a ParentAnimation is used in a Transition, it will animate any ParentChange that has occurred during the state change. This can be overridden by setting a specific target item using the target property. Like any other animation element, a ParentAnimation can be applied in a number of ways, including transitions, behaviors and property value sources. The QML Animation and Transitions documentation shows a variety of methods for creating animations. See also QML Animation and Transitions and Animation basics example. Property DocumentationThe new parent to animate to. If the ParentAnimation is defined within a Transition or Behavior, this value defaults to the value defined in the end state of the Transition, or the value of the property change that triggered the Behavior. The item to reparent. When used in a transition, if no target is specified, all ParentChange occurrences are animated by the ParentAnimation. 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: myItem via: topLevelItem // ... }
© 2008-2011 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide. All other trademarks are property of their respective owners. Privacy Policy Licensees holding valid Qt Commercial licenses may use this document in accordance with the Qt Commercial License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Nokia. Alternatively, this document may be used under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. |