PropertyAction QML Type
Especifica los cambios inmediatos de las propiedades durante la animación. Más...
| Import Statement: | import QtQuick |
| Inherits: |
Propiedades
- exclude : list<QtObject>
- properties : string
- property : string
- target : QtObject
- targets : list<QtObject>
- value : var
Descripción detallada
PropertyAction se utiliza para especificar un cambio de propiedad inmediato durante una animación. El cambio de propiedad no es animado.
Es útil para establecer valores de propiedades no animadas durante una animación.
Por ejemplo, aquí hay un SequentialAnimation que establece la propiedad opacity de la imagen a .5, anima el ancho de la imagen, y luego establece opacity de nuevo 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 también es útil para establecer el punto exacto en el que debe producirse un cambio de propiedad durante un Transition. Por ejemplo, si PropertyChanges se utilizara en un State para rotar un elemento alrededor de un transformOrigin particular, podría implementarse así:
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" } } }
Sin embargo, con este código, el transformOrigin no se establece hasta después de la animación, ya que se toma un State para definir los valores al final de una transición. La animación rotaría en el valor por defecto transformOrigin, luego saltaría a Item.BottomRight. Para arreglar esto, inserte una PropertyAction antes de que comience RotationAnimation:
transitions: Transition { SequentialAnimation { PropertyAction { target: rect; property: "transformOrigin" } RotationAnimation { duration: 1000; direction: RotationAnimation.Counterclockwise } } }
Esto establece inmediatamente la propiedad transformOrigin al valor definido en el estado final de la Transition (es decir, el valor definido en el objeto PropertyAction) para que la animación de rotación comience con el origen de transformación correcto.
Ver también Animación y Transiciones en Qt Quick y Qt Qml.
Documentación de Propiedades
exclude : list<QtObject> [read-only]
Esta propiedad contiene los objetos que no deben ser afectados por esta acción.
Véase también targets.
Estas propiedades determinan los elementos y sus propiedades que se ven afectados por esta acción.
Los detalles de cómo se interpretan estas propiedades en diferentes situaciones se tratan en la documentación de corresponding PropertyAnimation .
Véase también exclude.
value : var
Esta propiedad contiene el valor que se establecerá en la propiedad.
Si PropertyAction se define dentro de Transition o Behavior, este valor es por defecto el valor definido en el estado final de Transition, o el valor del cambio de propiedad que desencadenó 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.