Sur cette page

PropertyAction QML Type

Spécifie les modifications immédiates des propriétés pendant l'animation. En savoir plus...

Import Statement: import QtQuick
Inherits:

Animation

Propriétés

Description détaillée

PropertyAction permet de spécifier une modification immédiate d'une propriété au cours d'une animation. La modification de la propriété n'est pas animée.

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

Par exemple, voici une action « SequentialAnimation » qui définit la propriété « opacity » de l’image sur « .5 », anime la largeur de l’image, puis redéfinit « opacity » sur « 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 moment précis où un changement de propriété doit se produire au cours d’une animation ( Transition). Par exemple, si la propriété PropertyChanges était utilisée dans une animation ( State ) pour faire pivoter un élément autour d’un axe de rotation ( transformOrigin) particulier, cela pourrait être implémenté comme suit :

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"
        }
    }
}

Cependant, avec ce code, la propriété « transformOrigin » n’est définie qu’après l’animation, car une « State » est utilisée pour définir les valeurs à la fin d’une transition. L’animation effectuerait une rotation selon la valeur par défaut de « transformOrigin », puis passerait brusquement à « Item.BottomRight ». Pour corriger cela, insérez une « PropertyAction » avant le début de la « RotationAnimation » :

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

Cela définit immédiatement la propriété transformOrigin sur la valeur définie dans l’état final de l’ 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 également 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 concernés par cette action.

Les détails concernant l’interprétation de ces propriétés dans différentes situations sont abordés dans la documentation « corresponding » ( PropertyAnimation ).

Voir également exclude.

value : var

Cette propriété contient la valeur à attribuer à la propriété.

Si l'PropertyAction est définie dans un Transition ou un Behavior, cette valeur prend par défaut la valeur définie dans l'état final de l'Transition, ou la valeur de la modification de propriété qui a déclenché l'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.