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.
Property ドキュメント
これらのプロパティは、このアクションによって影響を受けるアイテムとそのプロパティを決定する。
これらのプロパティがさまざまな状況でどのように解釈されるかの詳細は、corresponding PropertyAnimation ドキュメントに記載されています。
excludeも参照してください 。
value : var |
このプロパティは、プロパティに設定される値を保持します。
PropertyAction がTransition またはBehavior 内で定義されている場合、この値のデフォルトは、Transition の終了状態で定義されている値、またはBehavior のトリガーとなったプロパティ変更の値です。
© 2025 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.