The HistoryState type provides a means of returning to a previously active substate. More...
Import Statement: | import QtQml.StateMachine 6.4 |
Since: | Qt 5.4 |
Inherits: |
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 } } } } }
By default, a history state is shallow, meaning that it will not remember nested states. This can be configured through the historyType property.
See also StateMachine and State.
defaultState : QAbstractState |
The default state of this history state.
The default state indicates the state to transition to if the parent state has never been entered before.
historyType : enumeration |
The type of history that this history state records.
The default value of this property is HistoryState.ShallowHistory.
This enum specifies the type of history that a HistoryState records.
As part of the free Business evaluation, we offer a free welcome call for companies, to talk about your requirements, and how the Felgo SDK & Services can help you. Just sign up and schedule your call.
Sign up now to start your free Business evaluation: