IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

ParentAnimation QML Type

Animates changes in parent values.

This type was introduced in Qt 5.0.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

ParentAnimation QML Type

  • Import Statement: import QtQuick

  • Since:: Qt 5.0

  • Inherits:: Animation

  • Group: ParentAnimation is part of qtquick-animation-properties

Detailed Description

ParentAnimation 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:

 
Sélectionnez
import QtQuick 2.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.

ParentAnimation is typically used within a Transition in conjunction with a ParentChange. When used in this manner, it animates any ParentChange that has occurred during the state change. This can be overridden by setting a specific target item using the target property.

See Also

Property Documentation

 

newParent : Item

The new parent to animate to.

If the ParentAnimation is defined within a Transition, this value defaults to the value defined in the end state of the Transition.

target : Item

The item to reparent.

When used in a transition, if no target is specified, all ParentChange occurrences are animated by the ParentAnimation.

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.

 
Sélectionnez
ParentAnimation {
    target: myItem
    via: topLevelItem
    // ...
}

This only works when the ParentAnimation is used in a Transition in conjunction with a ParentChange.

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+