PropertyAction QML Type
アニメーション中のプロパティの即時変更を指定します。詳細...
| Import Statement: | import QtQuick |
| Inherits: |
プロパティ
- exclude : list<QtObject>
- properties : string
- property : string
- target : QtObject
- targets : list<QtObject>
- value : var
詳細な説明
PropertyAction は、アニメーション中にプロパティを即座に変更するために使用されます。このプロパティの変更にはアニメーションは適用されません。
これは、アニメーションの途中で非アニメーションのプロパティ値を設定する際に役立ちます。
たとえば、以下のSequentialAnimation では、画像のopacity プロパティを.5 に設定し、画像の幅をアニメーション処理した後、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は、Transition 中にプロパティの変更が行われる正確なポイントを設定する場合にも役立ちます。例えば、PropertyChanges をState で使用して、特定のtransformOrigin を中心にアイテムを回転させる場合、次のように実装できます:
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"
}
}
}しかし、このコードでは、State は遷移の終了時の値を定義するものとして扱われるため、transformOrigin はアニメーション終了後まで設定されません。その結果、アニメーションはデフォルトのtransformOrigin で回転し、その後Item.BottomRight にジャンプしてしまいます。これを修正するには、RotationAnimation の開始前にPropertyActionを挿入します:
transitions: Transition {
SequentialAnimation {
PropertyAction { target: rect; property: "transformOrigin" }
RotationAnimation { duration: 1000; direction: RotationAnimation.Counterclockwise }
}
}これにより、transformOrigin プロパティが直ちにTransition の終了状態で定義された値(つまり、PropertyActionオブジェクトで定義された値)に設定され、回転アニメーションが正しいトランスフォーム原点から開始されるようになります。
「 Qt Quick 」の「アニメーションとトランジション」および Qt Qml。
プロパティのドキュメント
exclude : list<QtObject> [read-only]
このプロパティには、このアクションの影響を受けないようにすべきオブジェクトが格納されます。
「targets」も参照してください 。
これらのプロパティは、このアクションの影響を受ける項目とそのプロパティを決定します。
さまざまな状況においてこれらのプロパティがどのように解釈されるかについての詳細は、『corresponding 』PropertyAnimation のドキュメントに記載されています。
「exclude」も参照してください 。
value : var
このプロパティには、そのプロパティに設定される値が格納されます。
PropertyAction がTransition またはBehavior 内で定義されている場合、この値はデフォルトで、Transition の終了状態で定義された値、または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.