In questa pagina

PropertyAction QML Type

Specifica le modifiche immediate alle proprietà durante l'animazione. Altro...

Import Statement: import QtQuick
Inherits:

Animation

Proprietà

Descrizione dettagliata

PropertyAction viene utilizzato per specificare una modifica immediata di una proprietà durante un'animazione. La modifica della proprietà non viene animata.

È utile per impostare valori di proprietà non animati durante un'animazione.

Ad esempio, ecco un SequentialAnimation che imposta la proprietà opacity dell'immagine su .5, anima la larghezza dell'immagine, quindi riporta opacity a 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 è utile anche per impostare il punto esatto in cui deve avvenire una modifica della proprietà durante un’animazione ( Transition). Ad esempio, se PropertyChanges fosse utilizzato in un’animazione ( State ) per ruotare un elemento attorno a un particolare transformOrigin, potrebbe essere implementato in questo modo:

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

Tuttavia, con questo codice, la proprietà ` transformOrigin ` non viene impostata fino al termine dell’animazione, poiché viene utilizzato un ` State ` per definire i valori alla fine di una transizione. L’animazione ruoterebbe in base all’asse predefinito ` transformOrigin`, per poi passare all’asse ` Item.BottomRight`. Per risolvere questo problema, inserire un `PropertyAction` prima dell’inizio dell’` RotationAnimation `:

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

Questo imposta immediatamente la proprietà transformOrigin sul valore definito nello stato finale della transizione Transition (ovvero il valore definito nell'oggetto PropertyAction), in modo che l'animazione di rotazione inizi con l'origine di trasformazione corretta.

Vedi anche Animazioni e transizioni in Qt Quick e Qt Qml.

Documentazione sulle proprietà

exclude : list<QtObject> [read-only]

Questa proprietà contiene gli oggetti che non devono essere interessati da questa azione.

Vedi anche targets.

properties : string

property : string

target : QtObject

targets : list<QtObject> [read-only]

Queste proprietà determinano gli elementi e le loro proprietà interessati da questa azione.

I dettagli su come queste proprietà vengono interpretate nelle diverse situazioni sono descritti nella documentazione relativa a " corresponding " PropertyAnimation.

Vedi anche exclude.

value : var

Questa proprietà contiene il valore da assegnare alla proprietà stessa.

Se l'PropertyAction è definita all'interno di un Transition o di un Behavior, questo valore assume per impostazione predefinita il valore definito nello stato finale dell'Transition, oppure il valore della modifica della proprietà che ha attivato 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.