RotationAnimation QML Type
回転値の変化をアニメーション化する。詳細...
Import Statement: | import QtQuick |
Inherits: |
プロパティ
詳しい説明
RotationAnimation はPropertyAnimation に特化したもので、アニメーション中の回転方向を制御します。
デフォルトでは、数値の変化方向に回転します。0 から 240 への回転は時計回りに 240 度回転し、240 から 0 への回転は反時計回りに 240 度回転します。回転の方向を指定するには、direction プロパティを設定します。
次の例では、RotationAnimationを使って、最短経路で状態間の回転をアニメートしている:
import QtQuick Item { width: 300; height: 300 Rectangle { id: rect width: 150; height: 100; anchors.centerIn: parent color: "red" antialiasing: true states: State { name: "rotated" PropertyChanges { target: rect; rotation: 180 } } transitions: Transition { RotationAnimation { duration: 1000; direction: RotationAnimation.Counterclockwise } } } MouseArea { anchors.fill: parent; onClicked: rect.state = "rotated" } }
RotationAnimationはtarget
。便利なことに、RotationAnimationをトランジションで使うと、"rotation "または "angle "という名前のプロパティがすべて回転する。これをオーバーライドするには、properties またはproperty を使って独自のプロパティを指定します。
また、Rectangle は、デフォルトのtransformOrigin (Item.Center
)を中心に回転することに注意してください。異なるトランスフォームの原点を使用するには、PropertyChanges オブジェクトで原点を設定し、PropertyAction を使用してアニメーションの開始時に変更を適用します。詳細はPropertyAction のドキュメントを参照してください。
他のアニメーションタイプと同様に、RotationAnimationは、トランジション、ビヘイビア、プロパティ値のソースなど、さまざまな方法で適用することができます。 Qt Quick の「 Animation and Transitions」ドキュメントでは、アニメーションを作成するためのさまざまな方法を紹介しています。
Qt Quick の Animation and TransitionsとQt Quick Examples - Animationも参照してください 。
プロパティの説明
direction : enumeration |
このプロパティは、回転の方向を保持します。
指定できる値は次のとおりです:
定数 | 説明 |
---|---|
RotationAnimation.Numerical | (デフォルト) 2つの数値の間を線形補間して回転する。10 から350 への回転は、時計回りに 340 度回転する。 |
RotationAnimation.Clockwise | 2つの値の間を時計回りに回転 |
RotationAnimation.Counterclockwise | 2つの値の間を反時計回りに回転 |
RotationAnimation.Shortest | 最短のアニメーションパスを生成する方向に回転する。10 から350 への回転は、20 度を反時計回りに回転させる。 |
from : real |
このプロパティは、アニメーションの開始値を保持します。
例えば、angle
の値が 100 に達するまで、次のアニメーションは適用されません:
Item { states: [ // ... ] transitions: Transition { RotationAnimation { properties: "angle"; from: 100; duration: 2000 } } }
RotationAnimation がTransition またはBehavior 内で定義されている場合、この値はTransition の開始状態で定義された値、またはBehavior がトリガーされた時点でのプロパティの現在値がデフォルトとなります。
Qt Quick の「アニメーションとトランジション」も参照してください 。
to : real |
このプロパティは、アニメーションの終了値を保持します。
RotationAnimation がTransition またはBehavior 内で定義されている場合、この値のデフォルトはTransition の終了状態で定義された値、またはBehavior をトリガーしたプロパティ変更の値です。
Qt Quick の「アニメーションとトランジション」も参照してください 。
© 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.