이 페이지에서

ParentChange QML Type

상태 변경 시 항목의 상위 항목을 재설정하는 방법을 지정합니다. 더 보기...

Import Statement: import QtQuick

속성

상세 설명

ParentChange는 화면상의 시각적 모양(위치, 크기, 회전, 확대/축소 비율)을 유지한 채 항목의 부모를 변경합니다. 그런 다음 전환 효과를 지정하여 항목을 최종 의도된 모양으로 이동, 크기 조정, 회전 또는 확대/축소할 수 있습니다.

ParentChange는 복잡한 변환이 포함되지 않은 경우에만 시각적 외관을 유지할 수 있습니다. 보다 구체적으로 말하면, 부모 변경에 관련된 항목(즉, 원래 부모와 새 부모의 공통 조상 트리에 있는 항목) 중 어느 하나라도 transform 속성이 설정되어 있는 경우에는 작동하지 않습니다.

아래 예제에서는 큰 빨간색 사각형과 작은 파란색 사각형을 나란히 표시합니다. blueRect 를 클릭하면 “부모 변경” 상태로 전환됩니다. 즉, 부모가 redRect 로 변경되고, ParentChange에 지정된 대로 빨간색 사각형 내 (10, 10) 위치에 배치됩니다.

import QtQuick

Item {
    width: 200; height: 100

    Rectangle {
        id: redRect
        width: 100; height: 100
        color: "red"
    }

    Rectangle {
        id: blueRect
        x: redRect.width
        width: 50; height: 50
        color: "blue"

        states: State {
            name: "reparented"
            ParentChange { target: blueRect; parent: redRect; x: 10; y: 10 }
        }

        MouseArea { anchors.fill: parent; onClicked: blueRect.state = "reparented" }
    }
}

부모 객체의 재할당에 영향을 미치는 파란색 사각형의 상태 변경

ParentAnimation 를 사용하여 전환의 어느 시점에서 ParentChange가 발생하도록 할지 지정할 수 있습니다.

PropertyChanges 와 달리, ParentChange는 Item 기반의 대상을 기대한다는 점에 유의하십시오. 임의의 객체(예를 들어, Timer의 부모를 변경하는 데는 사용할 수 없음)에서는 작동하지 않습니다.

속성 문서

height : real

rotation : real

scale : real

width : real

x : real

y : real

이 속성들은 이 상태에서 항목의 새로운 위치, 크기, 배율 및 회전 각도를 저장합니다.

parent : Item

이 속성은 해당 상태의 항목에 대한 새로운 상위 항목을 저장합니다.

target : 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.