HistoryState QML Type
HistoryState 유형은 이전에 활성 상태였던 하위 상태로 되돌아갈 수 있는 방법을 제공합니다. 더 보기...
| Import Statement: | import QtQml.StateMachine 6.12 |
| Inherits: |
속성
- defaultState : QAbstractState
- historyType : enumeration
상세 설명
히스토리 상태는 부모 상태가 마지막으로 종료되었을 때 부모 상태가 속해 있던 자식 상태를 나타내는 의사 상태입니다. 히스토리 상태를 대상으로 하는 전환은 사실 부모 상태의 다른 자식 상태 중 하나로의 전환입니다. HistoryState는 Qt State Machine QML API의 일부입니다.
defaultState 속성을 사용하여, 부모 상태에 한 번도 진입한 적이 없는 경우 진입해야 할 상태를 설정할 수 있습니다.
사용 예
import QtQuick
import QtQml.StateMachine as DSM
Rectangle {
Button {
anchors.fill: parent
id: button
text: "Press me"
DSM.StateMachine {
id: stateMachine
initialState: parentState
running: true
DSM.State {
id: parentState
initialState: child2
onEntered: console.log("parentState entered")
onExited: console.log("parentState exited")
DSM.State {
id: child1
onEntered: console.log("child1 entered")
onExited: console.log("child1 exited")
}
DSM.State {
id: child2
onEntered: console.log("child2 entered")
onExited: console.log("child2 exited")
}
DSM.HistoryState {
id: historyState
defaultState: child1
}
DSM.SignalTransition {
targetState: historyState
// Clicking the button will cause the state machine to enter the child state
// that parentState was in the last time parentState was exited, or the history state's default
// state if parentState has never been entered.
signal: button.clicked
}
}
}
}
}기본적으로 히스토리 상태는 얕게 구성되며, 이는 중첩된 상태를 기억하지 않음을 의미합니다. 이는 historyType 속성을 통해 구성할 수 있습니다.
StateMachine 및 State도 참조하십시오 .
속성 설명서
defaultState : QAbstractState
이 히스토리 상태의 기본 상태입니다.
기본 상태는 상위 상태로 이전에 진입한 적이 없는 경우 전환해야 할 상태를 나타냅니다.
historyType : enumeration
이 히스토리 상태가 기록하는 히스토리 유형입니다.
이 속성의 기본값은 ` HistoryState.ShallowHistory`입니다.
이 열거형은 HistoryState 가 기록하는 기록 유형을 지정합니다.
- HistoryState.ShallowHistory 부모 상태의 직계 자식 상태만 기록됩니다. 이 경우, 히스토리 상태를 대상으로 하는 전환은 부모 상태가 마지막으로 종료되었을 때 있던 직계 자식 상태로 이동하게 됩니다. 이것이 기본값입니다.
- HistoryState.DeepHistory 중첩된 상태가 기록됩니다. 이 경우, 히스토리 상태를 대상으로 하는 전환은 부모 상태가 마지막으로 종료되었을 때 있던 가장 깊게 중첩된 하위 상태로 이동하게 됩니다.
© 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.