Qt 5.6 | Qt Quick | QML Types | PropertyAction QML Type

Qt 5.6.2 Reference Documentation

# PropertyAction QML Type

Specifies immediate property changes during animation More...

Import Statement: | import QtQuick 2.5
Inherits: | Animation

- List of all members, including inherited members

## Properties

- exclude : list<Object>
- properties : string
- property : string
- target : Object
- targets : list<Object>
- value : any

## Detailed Description

PropertyAction is used to specify an immediate property change during an animation. The property change is not animated.

It is useful for setting non-animated property values during an animation.

For example, here is a SequentialAnimation that sets the image's opacity property to `.5`, animates the width of the image, then sets opacity back to `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 is also useful for setting the exact point at which a property change should occur during a Transition. For example, if PropertyChanges was used in a State to rotate an item around a particular transformOrigin, it might be implemented like this:

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

However, with this code, the `transformOrigin` is not set until after the animation, as a State is taken to define the values at the end of a transition. The animation would rotate at the default `transformOrigin`, then jump to `Item.BottomRight`. To fix this, insert a PropertyAction before the RotationAnimation begins:

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

This immediately sets the `transformOrigin` property to the value defined in the end state of the Transition (i.e. the value defined in the PropertyAction object) so that the rotation animation begins with the correct transform origin.

See also Animation and Transitions in Qt Quick and Qt QML.

## Property Documentation

exclude : list<Object>

This property holds the objects that should not be affected by this action.

See also targets.

properties : string

These properties determine the items and their properties that are affected by this action.

The details of how these properties are interpreted in different situations is covered in the corresponding PropertyAnimation documentation.

See also exclude.

property : string

These properties determine the items and their properties that are affected by this action.

The details of how these properties are interpreted in different situations is covered in the corresponding PropertyAnimation documentation.

See also exclude.

target : Object

These properties determine the items and their properties that are affected by this action.

The details of how these properties are interpreted in different situations is covered in the corresponding PropertyAnimation documentation.

See also exclude.

targets : list<Object>

These properties determine the items and their properties that are affected by this action.

The details of how these properties are interpreted in different situations is covered in the corresponding PropertyAnimation documentation.

See also exclude.

value : any

This property holds the value to be set on the property.

If the PropertyAction is defined within a Transition or Behavior, this value defaults to the value defined in the end state of the Transition, or the value of the property change that triggered the Behavior.