Behavior QML Type
속성 변경 시 적용될 기본 애니메이션을 정의합니다. 더 보기...
| Import Statement: | import QtQuick |
속성
- animation : Animation
- enabled : bool
- targetProperty
(since QtQuick 2.15)- targetProperty.name : string
(since QtQuick 2.15) - targetProperty.object : QtObject
(since QtQuick 2.15)
- targetProperty.name : string
- targetValue : Variant
(since QtQuick 2.13)
상세 설명
Behavior는 특정 속성 값이 변경될 때마다 적용될 기본 애니메이션을 정의합니다.
예를 들어, 다음 Behaviors는 Rectangle 의 width 값이 변경될 때마다 NumberAnimation 가 실행되도록 정의합니다. MouseArea 를 클릭하면 width 가 변경되어 Behaviors의 애니메이션이 트리거됩니다:
import QtQuick
Rectangle {
id: rect
width: 100; height: 100
color: "red"
Behavior on width {
NumberAnimation { duration: 1000 }
}
MouseArea {
anchors.fill: parent
onClicked: rect.width = 50
}
}한 속성에는 하나의 Behavior만 할당될 수 있다는 점에 유의하십시오. Behavior 내에서 여러 애니메이션을 제공하려면 ParallelAnimation 또는 SequentialAnimation 를 사용하십시오.
상태 변경에 비하비어( Transition )가 지정되어 있고, 해당 비하비어가 비하비어(Behavior)와 동일한 속성을 가리키는 경우, 해당 상태 변경에 대해서는 비하비어( Transition ) 애니메이션이 비하비어(Behavior)를 재정의합니다. 비하비어(Behaviors)를 사용하여 상태 변경을 애니메이션화하는 방법에 대한 일반적인 안내는 ‘상태와 함께 비하비어( Qt Quick ) 사용하기’를 참조하십시오.
또한 ' Qt Quick 의 애니메이션 및 전환', 'Behavior 예제' 및 Qt Qml.
속성 설명서
animation : Animation [default]
이 속성은 해당 동작이 트리거될 때 실행될 애니메이션을 지정합니다.
enabled : bool
이 속성은 추적 대상 속성의 값이 변경될 때 해당 동작이 트리거될지 여부를 결정합니다.
기본적으로 동작은 활성화된 상태입니다.
targetProperty group
targetProperty.name : string [read-only, since QtQuick 2.15]
targetProperty.object : QtObject [read-only, since QtQuick 2.15]
| 속성 | 설명 |
|---|---|
| 이름 | 이 속성은 이 비헤이비어가 제어하는 속성의 이름을 저장합니다. |
| 객체 | 이 속성은 이 비헤이비어가 제어하는 속성의 객체를 저장합니다. |
이 속성은 제어 대상 속성의 이름이나 객체를 기반으로 사용자 정의 비헤이비어를 정의하는 데 사용할 수 있습니다.
다음 예제는 제어하는 속성이 변경될 때 대상 객체를 페이드 아웃 및 페이드 인하는 비헤이비어를 정의합니다:
// FadeBehavior.qml
import QtQuick 2.15
Behavior {
id: root
property Item fadeTarget: targetProperty.object
SequentialAnimation {
NumberAnimation {
target: root.fadeTarget
property: "opacity"
to: 0
easing.type: Easing.InQuad
}
PropertyAction { } // actually change the controlled property between the 2 other animations
NumberAnimation {
target: root.fadeTarget
property: "opacity"
to: 1
easing.type: Easing.OutQuad
}
}
}이를 통해 텍스트가 변경될 때 애니메이션을 적용할 수 있습니다:
import QtQuick 2.15
Text {
id: root
property int counter
text: counter
FadeBehavior on text {}
Timer {
running: true
repeat: true
interval: 1000
onTriggered: ++root.counter
}
}이 속성들은 QtQuick 2.15에서 도입되었습니다.
targetValue : Variant [read-only, since QtQuick 2.13]
이 속성은 Behavior가 제어하는 속성의 목표 값을 저장합니다. 이 값은 애니메이션이 시작되기 전에 Behavior에 의해 설정됩니다.
이 속성은 QtQuick 2.13에서 도입되었습니다.
© 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.