이 페이지에서

AnchorChanges QML Type

상태에 있는 항목의 앵커를 변경하는 방법을 지정합니다. 더 보기...

Import Statement: import QtQuick

속성

상세 설명

AnchorChanges 유형은 State 내 항목의 앵커를 수정하는 데 사용됩니다.

AnchorChanges는 항목의 여백을 수정하는 데 사용할 수 없습니다. 이를 위해서는 대신 PropertyChanges 를 사용하십시오.

다음 예제에서는 AnchorChanges를 사용하여 항목의 상단 및 하단 앵커를 변경하고, 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" }
}

두 상태 사이에서 닻의 위치를 바꾸는 빨간 사각형

AnchorChanges는 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 를 포함합니다.

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