HistoryState QML 类型
The HistoryState type provides a means of returning to a previously active substate. More...
导入语句 | import QtQml.StateMachine 6.7 |
继承 |
属性
- defaultState : QAbstractState
- historyType : enumeration
详细描述
A history state is a pseudo-state that represents the child state that the parent state was in the last time the parent state was exited. A transition with a history state as its target is in fact a transition to one of the other child states of the parent state. HistoryState is part of Qt State Machine QML API.
Use the defaultState property to set the state that should be entered if the parent state has never been entered.
示例用法
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 记录嵌套状态。在这种情况下,以历史状态为目标的转变将结束于父状态上次退出时所处的最深嵌套的子状态。
© 2024 The Qt Company Ltd. 本文档中包含的文档贡献均属其各自所有者的版权。所提供的文档根据自由软件基金会发表的 GNU自由文档许可证第1.3版 的条款进行授权。Qt及其相关标志是芬兰和/或其他国家/地区的The Qt Company Ltd.的商标。所有其他商标均为其各自所有者的财产。