このページでは

NumberAnimation QML Type

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

Import Statement: import QtQuick
Inherits:

PropertyAnimation

Inherited By:

SmoothedAnimation and SpringAnimation

プロパティ

詳細な説明

NumberAnimationは、数値が変化した際に適用されるアニメーションを定義する、PropertyAnimation 専用のアニメーションです。

以下は、Rectangle のx プロパティに、プロパティ値ソースとしてNumberAnimationを適用した例です。これにより、x の値が現在の値から50へと、1000ミリ秒かけてアニメーションされます:

import QtQuick

Rectangle {
    width: 100; height: 100
    color: "red"

    NumberAnimation on x { to: 50; duration: 1000 }
}

他のアニメーションタイプと同様に、NumberAnimationもトランジション、ビヘイビア、プロパティ値ソースなど、さまざまな方法で適用できます。「 Qt Quick のアニメーションとトランジション」のドキュメントには、アニメーションを作成するためのさまざまな方法が紹介されています。

なお、NumberAnimationは、追跡対象の数値に不規則な変化がある場合、アニメーションが滑らかに動作しないことがあります。その場合は、代わりにSmoothedAnimation を使用してください。

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

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

from : real

このプロパティには、アニメーションの開始値が格納されます。

たとえば、x の値が100に達するまで、次のアニメーションは適用されません:

Item {
    states: [
        // ...
    ]

    transitions: Transition {
        NumberAnimation { properties: "x"; from: 100; duration: 200 }
    }
}

NumberAnimation がTransition またはBehavior 内で定義されている場合、この値はデフォルトで、Transition の開始状態で定義された値、あるいはBehavior がトリガーされた時点でのプロパティの現在の値になります。

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

to : real

このプロパティは、アニメーションの終了値を保持します。

NumberAnimation が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.