Sur cette page

PropertyAction QML Type

Spécifie les changements de propriétés immédiats pendant l'animation. Plus d'informations...

Import Statement: import QtQuick
Inherits:

Animation

Propriétés

Description détaillée

PropertyAction est utilisé pour spécifier un changement de propriété immédiat au cours d'une animation. Le changement de propriété n'est pas animé.

Elle est utile pour définir des valeurs de propriétés non animées au cours d'une animation.

Par exemple, voici une action SequentialAnimation qui définit la propriété opacity de l'image à .5, anime la largeur de l'image, puis redéfinit opacity à 1:

SequentialAnimation {
    PropertyAction { target: img; property: "opacity"; value: .5 }
    NumberAnimation { target: img; property: "width"; to: 300; duration: 1000 }
    PropertyAction { target: img; property: "opacity"; value: 1 }
}

PropertyAction est également utile pour définir le point exact auquel un changement de propriété doit se produire au cours d'une animation Transition. Par exemple, si PropertyChanges était utilisé dans une animation State pour faire pivoter un élément autour d'un point particulier transformOrigin, il pourrait être mis en œuvre de la manière suivante :

Item {
    width: 400; height: 400

    Rectangle {
        id: rect
        width: 200; height: 100
        color: "red"

        states: State {
            name: "rotated"
            PropertyChanges { target: rect; rotation: 180; transformOrigin: Item.BottomRight }
        }

        transitions: Transition {
            RotationAnimation { duration: 1000; direction: RotationAnimation.Counterclockwise }
        }

        MouseArea {
            anchors.fill: parent
            onClicked: rect.state = "rotated"
        }
    }
}

Toutefois, avec ce code, la valeur transformOrigin n'est définie qu'après l' animation, car une valeur State est utilisée pour définir les valeurs à la fin d' une transition. L'animation tournerait à la valeur par défaut transformOrigin, puis sauterait à Item.BottomRight. Pour résoudre ce problème, insérez une PropertyAction avant le début de RotationAnimation:

transitions: Transition {
    SequentialAnimation {
        PropertyAction { target: rect; property: "transformOrigin" }
        RotationAnimation { duration: 1000; direction: RotationAnimation.Counterclockwise }
    }
}

Cette action définit immédiatement la propriété transformOrigin à la valeur définie dans l'état final de Transition (c'est-à-dire la valeur définie dans l'objet PropertyAction), de sorte que l'animation de rotation commence avec l'origine de transformation correcte.

Voir également Animation et transitions dans Qt Quick et Qt Qml.

Documentation sur les propriétés

exclude : list<QtObject> [read-only]

Cette propriété contient les objets qui ne doivent pas être affectés par cette action.

Voir aussi targets.

properties : string

property : string

target : QtObject

targets : list<QtObject> [read-only]

Ces propriétés déterminent les éléments et leurs propriétés qui sont affectés par cette action.

La façon dont ces propriétés sont interprétées dans différentes situations est décrite en détail dans la documentation corresponding PropertyAnimation .

Voir également exclude.

value : var

Cette propriété contient la valeur à définir pour la propriété.

Si l'adresse PropertyAction est définie à l'intérieur d'une adresse Transition ou Behavior, cette valeur prend par défaut la valeur définie dans l'état final de l'adresse Transition, ou la valeur du changement de propriété qui a déclenché l'adresse Behavior.

© 2026 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 the GNU 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.