이 페이지에서

ParentAnimation QML Type

상위 값의 변경 사항을 애니메이션으로 표시합니다. 더 보기...

Import Statement: import QtQuick
Inherits:

Animation

속성

상세 설명

ParentAnimation은 Item 의 부모 변경을 애니메이션 처리하는 데 사용됩니다.

예를 들어, 다음 ParentChange 은 클릭 시 blueRect 을 redRect 의 자식 항목으로 변경합니다. 전환 중에 적용될 NumberAnimation 을 정의하는 ParentAnimation을 포함함으로써, 항목이 새로운 부모 항목으로 이동할 때 부드럽게 애니메이션이 적용되도록 보장합니다:

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 }
        }

        transitions: Transition {
            ParentAnimation {
                NumberAnimation { properties: "x,y"; duration: 1000 }
            }
        }

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

ParentAnimation에는 임의의 개수의 애니메이션을 포함할 수 있습니다. 이러한 애니메이션은 병렬로 실행되며, 순차적으로 실행하려면 ` SequentialAnimation` 내에 정의해야 합니다.

클리핑이 활성화된 항목 간에 부모-자식 관계를 재설정하는 경우와 같이, 클리핑이 활성화되지 않은 다른 항목을 통해 부모 변경을 애니메이션으로 표현하는 것이 유용한 경우가 있습니다. 이러한 항목은 ` via ` 속성을 사용하여 설정할 수 있습니다.

ParentAnimation은 일반적으로 Transition 내에서 ParentChange 와 함께 사용됩니다. 이러한 방식으로 사용될 경우, 상태 변경 중에 발생한 모든 ParentChange 에 대해 애니메이션을 적용합니다. 이는 target 속성을 사용하여 특정 대상 항목을 설정함으로써 재정의할 수 있습니다.

Qt Quick 의 ‘애니메이션 및 전환 ’ 및 Qt Quick 예제 - ‘애니메이션’도 참조하십시오 .

속성 설명서

newParent : Item

애니메이션이 적용될 새로운 부모 요소입니다.

ParentAnimation 가 Transition 내에 정의된 경우, 이 값은 기본적으로 Transition 의 종료 상태에 정의된 값을 따릅니다.

target : Item

부모를 변경할 항목.

전환 효과에서 사용될 때, 대상이 지정되지 않으면 모든 ` ParentChange ` 인스턴스는 ` ParentAnimation`에 의해 애니메이션이 적용됩니다.

via : Item

부모 관계를 재설정할 대상입니다. 이 기능을 사용하면 기존 부모와 새 부모가 모두 클리핑된 상태에서도 클리핑되지 않은 애니메이션을 재생할 수 있습니다.

ParentAnimation {
    target: myItem
    via: topLevelItem
    // ...
}

참고: 이 기능은 ParentAnimation 이 Transition 내에서 ParentChange 과 함께 사용될 때만 작동합니다.

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