このページでは

C

AnchorChanges QML Type

ステート内のアイテムのアンカーを変更する方法を指定します。詳細...

Import Statement: import QtQuick
Since: Qt Quick Ultralite 1.0

プロパティ

詳細説明

AnchorChanges 型は、State の項目のアンカーを変更するために使用されます。

AnchorChanges はアイテムのマージンを変更するために使用することはできません。その場合は、PropertyChanges を使用してください。

次の例では、AnchorChanges を使ってアイテムの上下のアンカーを変更し、PropertyChanges を使って上下のアンカーのマージンを変更しています:

import QtQuick 2.15

Rectangle {
    id: window
    width: 120; height: 120
    color: "black"

    Rectangle { id: anchorRectStart; x: 60; y: 60; height: 60; width: 60; color: "yellow"}
    Rectangle { id: anchorRectEnd; x: 0; y: 0; height: 60; width: 60; color: "blue"}

    Rectangle {
        id: myRect; color: "red"
        anchors {
            top: anchorRectStart.top
            bottom: anchorRectStart.bottom
            left: anchorRectStart.left
            right: anchorRectStart.right
            topMargin: 10
            bottomMargin: 10
            leftMargin: 10
            rightMargin: 10
        }
    }

    states: State {
        name: "reanchored"
        AnchorChanges {
            target: myRect
            anchors {
                top: anchorRectEnd.top
                bottom: anchorRectEnd.bottom
                left: anchorRectEnd.left
                right: anchorRectEnd.right
            }
        }
        PropertyChanges {
            target: myRect
            anchors {
                topMargin: 20
                bottomMargin: 20
                leftMargin: 20
                rightMargin: 20
            }
        }
    }

    MouseArea { anchors.fill: parent; onClicked: window.state = "reanchored" }
}

アンカーの余白の変更は、NumberAnimation を使ってアニメーション化することができます。

アンカーの詳細については、アンカーレイアウトを参照してください。

プロパティの説明

anchors group

anchors.baseline : AnchorLine

anchors.bottom : AnchorLine

anchors.horizontalCenter : AnchorLine

anchors.left : AnchorLine

anchors.right : AnchorLine

anchors.top : AnchorLine

anchors.verticalCenter : AnchorLine

これらのプロパティは、アイテムのそれぞれのアンカーを変更する。


target : Item

このプロパティは、アンカーの変更が適用されるItem を保持します。


特定の Qt ライセンスの下で利用可能です。
詳細を確認してください。