このページでは

ColorAnimation QML Type

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

Import Statement: import QtQuick
Inherits:

PropertyAnimation

プロパティ

詳細な説明

ColorAnimationは、色値が変更された際に適用されるアニメーションを定義する、PropertyAnimation の特殊な実装です。

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

import QtQuick

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

    ColorAnimation on color { to: "yellow"; duration: 1000 }
}

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

利便性のため、Transition でColorAnimationを使用する場合、状態変更の際に変更されたcolor のプロパティはすべてアニメーション処理されます。アニメーションに対してproperty またはproperties が明示的に設定されている場合は、代わりにそれらが使用されます。

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

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

from : color

このプロパティは、アニメーションを開始すべき色値を保持します。

たとえば、以下のアニメーションは、色値が「#c0c0c0」に達するまで適用されません:

Item {
    states: [
        // States are defined here...
    ]

    transitions: Transition {
        ColorAnimation { from: "#c0c0c0"; duration: 2000 }
    }
}

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

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

to : color

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

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