AnchorChanges QML Type

상태의 항목 앵커를 변경하는 방법을 지정합니다. 자세히...

Import Statement: import QtQuick

속성

상세 설명

앵커 변경 유형은 State 에서 항목의 앵커를 수정하는 데 사용됩니다.

앵커 변경은 항목의 여백을 수정하는 데 사용할 수 없습니다. 대신 PropertyChanges 을 사용하세요.

다음 예제에서는 앵커 변경을 사용하여 항목의 위쪽 및 아래쪽 앵커를 변경하고 PropertyChanges 을 사용하여 위쪽 및 아래쪽 앵커 여백을 변경합니다:

import QtQuick

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

    Rectangle { id: myRect; width: 50; height: 50; color: "red" }

    states: State {
        name: "reanchored"

        AnchorChanges {
            target: myRect
            anchors.top: window.top
            anchors.bottom: window.bottom
        }
        PropertyChanges {
            target: myRect
            anchors.topMargin: 10
            anchors.bottomMargin: 10
        }
    }

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

앵커 변경은 AnchorAnimation 을 사용하여 애니메이션을 적용할 수 있습니다.

//animate our anchor changes
Transition {
    AnchorAnimation {}
}

앵커 여백 변경은 NumberAnimation 을 사용하여 애니메이션을 적용할 수 있습니다.

앵커에 대한 자세한 내용은 앵커 레이아웃을 참조하세요.

속성 문서

anchors group

anchors.baseline : AnchorLine

anchors.bottom : AnchorLine

anchors.horizontalCenter : AnchorLine

anchors.left : AnchorLine

anchors.right : AnchorLine

anchors.top : AnchorLine

anchors.verticalCenter : AnchorLine

이러한 속성은 항목의 각 앵커를 변경합니다.

앵커를 재설정하려면 undefined 을 지정할 수 있습니다:

AnchorChanges {
    target: myItem
    anchors.left: undefined          //remove myItem's left anchor
    anchors.right: otherItem.right
}

target : Item

이 속성은 앵커 변경 사항이 적용될 Item 을 보유합니다.


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