このページでは

Flipable QML Type

反転可能な面を提供します。詳細...

Import Statement: import QtQuick
Inherits:

Item

プロパティ

詳細説明

Flipableは、カードのように表と裏を視覚的に「めくる」ことができるアイテムです。Rotation 、State 、Transition といったタイプと組み合わせて使用することで、めくり効果を生み出すことができます。

front およびback プロパティは、Flipable アイテムの表側と裏側にそれぞれ表示されるアイテムを保持するために使用されます。

使用例

次の例は、クリックされるたびに y 軸を中心に回転して反転する Flipable アイテムを示しています。

このフリップ可能なアイテムには、flipped というブール型のプロパティがあり、フリップ可能なアイテム内のMouseArea がクリックされるたびに切り替わります。flipped がtrueの場合、アイテムは「裏」の状態に変わります。この状態では、Rotation アイテムのangle が180度に設定され、反転効果が生まれます。flipped がfalseの場合、アイテムはデフォルトの状態に戻り、angle の値は0になります。

import QtQuick

Flipable {
    id: flipable
    width: 240
    height: 240

    property bool flipped: false

    front: Image { source: "front.png"; anchors.centerIn: parent }
    back: Image { source: "back.png"; anchors.centerIn: parent }

    transform: Rotation {
        id: rotation
        origin.x: flipable.width/2
        origin.y: flipable.height/2
        axis.x: 0; axis.y: 1; axis.z: 0     // set axis.y to 1 to rotate around y-axis
        angle: 0    // the default angle
    }

    states: State {
        name: "back"
        PropertyChanges { target: rotation; angle: 180 }
        when: flipable.flipped
    }

    transitions: Transition {
        NumberAnimation { target: rotation; property: "angle"; duration: 4000 }
    }

    MouseArea {
        anchors.fill: parent
        onClicked: flipable.flipped = !flipable.flipped
    }
}

Transition は、4秒かけて角度を変更するアニメーションを生成します。アイテムが「back」状態とデフォルト状態の間で切り替わる際、NumberAnimation は、角度の旧値と新値の間をアニメーションで移行させます。

状態の変更やデフォルト状態の詳細については「Qt Quick の状態」を、トランジション内でのアニメーションの動作に関する詳細については「 Qt Quick におけるアニメーションとトランジション」を参照してください。

「UI コンポーネント:Flipable の例」も参照してください 。

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

back : Item

front : Item

ひっくり返せるものの表と裏。

side : enumeration [read-only]

現在表示されている「Flipable」の面。取り得る値は、Flipable.Front およびFlipable.Back です。

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