HistoryState QML Type

HistoryState 유형은 이전에 활성 상태였던 대체물로 돌아가는 수단을 제공합니다. 더 보기...

Import Statement: import QtQml.StateMachine 6.8
Inherits:

QAbstractState

속성

상세 설명

히스토리 상태는 부모 상태가 마지막으로 종료될 때 부모 상태가 있었던 자식 상태를 나타내는 의사 상태입니다. 히스토리 상태를 대상으로 하는 전환은 실제로는 부모 상태의 다른 자식 상태 중 하나로 전환하는 것입니다. 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 속성을 통해 구성할 수 있습니다.

StateMachineState참조하세요 .

속성 문서

defaultState : QAbstractState

이 히스토리 상태의 기본 상태입니다.

기본 상태는 부모 상태가 이전에 입력된 적이 없는 경우 전환할 상태를 나타냅니다.


historyType : enumeration

이 기록 상태가 기록하는 기록 유형입니다.

이 프로퍼티의 기본값은 HistoryState.ShallowHistory입니다.

이 열거형은 HistoryState 가 기록하는 히스토리 유형을 지정합니다.

  • HistoryState.ShallowHistory 부모 상태의 바로 아래 자식 상태만 기록됩니다. 이 경우 히스토리 상태를 대상으로 하는 전환은 부모가 마지막으로 종료될 때 있었던 바로 아래 자식 상태로 끝납니다. 이것이 기본값입니다.
  • HistoryState.DeepHistory 중첩 상태가 기록됩니다. 이 경우 히스토리 상태를 대상으로 하는 트랜지션은 부모가 마지막으로 종료될 때 가장 깊게 중첩된 하위 상태로 끝납니다.

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