このページでは

RotationAnimation QML Type

回転値の変化をアニメーション表示します。詳細...

Import Statement: import QtQuick
Inherits:

PropertyAnimation

プロパティ

詳細な説明

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 』の「アニメーションとトランジション」のドキュメントでは、アニメーションを作成するためのさまざまな方法が紹介されています。

「Qt Quick のアニメーションとトランジション」および「Qt Quick の例 - アニメーション」も参照してください 。

プロパティのドキュメント

direction : enumeration

このプロパティは、回転の方向を保持します。

取り得る値は次のとおりです:

定数説明
RotationAnimation.Numerical(デフォルト) 2つの数値間を線形補間して回転させます。10 から350 への回転は、時計回りに340度回転します。
RotationAnimation.Clockwise2つの値の間で時計回りに回転します
RotationAnimation.Counterclockwise2つの値の間で反時計回りに回転させる
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 の「アニメーションとトランジション」も参照してください 。

© 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.