QHistoryState 类提供返回到先前活动子状态的手段。 更多...
头: | #include <QHistoryState> |
CMake: |
find_package(Qt6 REQUIRED COMPONENTS StateMachine)
target_link_libraries(mytarget PRIVATE Qt6::StateMachine) |
qmake: | QT += statemachine |
继承: | QAbstractState |
enum | HistoryType { ShallowHistory, DeepHistory } |
QHistoryState (QState * parent = nullptr) | |
QHistoryState (QHistoryState::HistoryType type , QState * parent = nullptr) | |
virtual | ~QHistoryState () |
QBindable<QAbstractTransition *> | bindableDefaultTransition () |
QBindable<QHistoryState::HistoryType> | bindableHistoryType () |
QAbstractState * | defaultState () const |
QAbstractTransition * | defaultTransition () const |
QHistoryState::HistoryType | historyType () const |
void | setDefaultState (QAbstractState * state ) |
void | setDefaultTransition (QAbstractTransition * transition ) |
void | setHistoryType (QHistoryState::HistoryType type ) |
void | defaultStateChanged () |
void | defaultTransitionChanged () |
void | historyTypeChanged () |
virtual bool | event (QEvent * e ) override |
virtual void | onEntry (QEvent * event ) override |
virtual void | onExit (QEvent * event ) override |
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 or more other child states of the parent state. QHistoryState is part of Qt State Machine Framework .
使用 setDefaultState () function to set the state that should be entered if the parent state has never been entered. Example:
QStateMachine machine; QState *s1 = new QState(); QState *s11 = new QState(s1); QState *s12 = new QState(s1); QHistoryState *s1h = new QHistoryState(s1); s1h->setDefaultState(s11); machine.addState(s1); QState *s2 = new QState(); machine.addState(s2); QPushButton *button = new QPushButton(); // Clicking the button will cause the state machine to enter the child state // that s1 was in the last time s1 was exited, or the history state's default // state if s1 has never been entered. s1->addTransition(button, SIGNAL(clicked()), s1h);
If more than one default state has to be entered, or if the transition to the default state(s) has to be acted upon, the defaultTransition should be set instead. Note that the eventTest() method of that transition will never be called: the selection and execution of the transition is done automatically when entering the history state.
By default a history state is shallow, meaning that it won't remember nested states. This can be configured through the historyType 特性。
This enum specifies the type of history that a QHistoryState records.
常量 | 值 | 描述 |
---|---|---|
QHistoryState::ShallowHistory
|
0
|
Only the immediate child states of the parent state are recorded. In this case a transition with the history state as its target will end up in the immediate child state that the parent was in the last time it was exited. This is the default. |
QHistoryState::DeepHistory
|
1
|
Nested states are recorded. In this case a transition with the history state as its target will end up in the most deeply nested descendant state the parent was in the last time it was exited. |
This property holds the default state of this history state
访问函数:
QAbstractState * | defaultState () const |
void | setDefaultState (QAbstractState * state ) |
通知程序信号:
void | defaultStateChanged () | [见下文注意事项] |
注意: 这是私有信号。它可以用于信号连接,但不能由用户发射。
[bindable]
defaultTransition
:
QAbstractTransition
*
注意: 此特性支持 QProperty 绑定。
This property holds the default transition of this history state
[bindable]
historyType
:
HistoryType
注意: 此特性支持 QProperty 绑定。
This property holds the type of history that this history state records
此特性的默认值为 QHistoryState::ShallowHistory .
Constructs a new shallow history state with the given parent 状态。
Constructs a new history state of the given type ,采用给定 parent 状态。
[虚拟]
QHistoryState::
~QHistoryState
()
Destroys this history state.
Returns this history state's default state. The default state indicates the state to transition to if the parent state has never been entered before.
注意: Getter function for property defaultState.
另请参阅 setDefaultState ().
[private signal]
void
QHistoryState::
defaultStateChanged
()
此信号被发射当 defaultState 特性改变。
注意: 这是私有信号。它可以用于信号连接,但不能由用户发射。
注意: 通知程序信号对于特性 defaultState .
另请参阅 QHistoryState::defaultState .
Returns this history state's default transition. The default transition is taken when the history state has never been entered before. The target states of the default transition therefore make up the default state.
注意: Getter function for property defaultTransition.
另请参阅 setDefaultTransition ().
[private signal]
void
QHistoryState::
defaultTransitionChanged
()
此信号被发射当 defaultTransition 特性改变。
注意: 这是私有信号。它可以用于信号连接,但不能由用户发射。
注意: 通知程序信号对于特性 defaultTransition .
另请参阅 QHistoryState::defaultTransition .
[override virtual protected]
bool
QHistoryState::
event
(
QEvent
*
e
)
重实现: QAbstractState::event (QEvent *e).
Returns the type of history that this history state records.
注意: Getter function for property historyType.
另请参阅 setHistoryType ().
[private signal]
void
QHistoryState::
historyTypeChanged
()
此信号被发射当 historyType 特性改变。
注意: 这是私有信号。它可以用于信号连接,但不能由用户发射。
注意: 通知程序信号对于特性 historyType .
另请参阅 QHistoryState::historyType .
[override virtual protected]
void
QHistoryState::
onEntry
(
QEvent
*
event
)
重实现: QAbstractState::onEntry (QEvent *event).
[override virtual protected]
void
QHistoryState::
onExit
(
QEvent
*
event
)
重实现: QAbstractState::onExit (QEvent *event).
Sets this history state's default state to be the given state . state must be a sibling of this history state.
Note that this function does not set state as the initial state of its parent.
注意: setter 函数对于特性 defaultState .
另请参阅 defaultState ().
Sets this history state's default transition to be the given transition . This will set the source state of the transition to the history state.
Note that the eventTest method of the transition will never be called.
注意: setter 函数对于特性 defaultTransition .
另请参阅 defaultTransition ().
设置 type of history that this history state records.
注意: setter 函数对于特性 historyType .
另请参阅 historyType ().