
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQHistoryState class provides a means of returning to a previously active substate.More...
| Header: | #include <QHistoryState> |
| Since: | Qt 4.6 |
| Inherits: | QAbstractState |
| enum | HistoryType { ShallowHistory, DeepHistory } |
| QHistoryState(QState * parent = 0) | |
| QHistoryState(HistoryType type, QState * parent = 0) | |
| ~QHistoryState() | |
| QAbstractState * | defaultState() const |
| HistoryType | historyType() const |
| void | setDefaultState(QAbstractState * state) |
| void | setHistoryType(HistoryType type) |
| virtual bool | event(QEvent * e) |
| virtual void | onEntry(QEvent * event) |
| virtual void | onExit(QEvent * event) |
TheQHistoryState class provides a means of returning to a previously active substate.
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.QHistoryState is part ofThe State Machine Framework.
Use thesetDefaultState() function to set the state that should be entered if the parent state has never been entered. Example:
QStateMachine machine;QState*s1=newQState();QState*s11=newQState(s1);QState*s12=newQState(s1);QHistoryState*s1h=newQHistoryState(s1);s1h->setDefaultState(s11);machine.addState(s1);QState*s2=newQState();machine.addState(s2);QPushButton*button=newQPushButton();// 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);
By default a history state is shallow, meaning that it won't remember nested states. This can be configured through thehistoryType property.
This enum specifies the type of history that aQHistoryState records.
| Constant | Value | Description |
|---|---|---|
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.
Access functions:
| QAbstractState * | defaultState() const |
| void | setDefaultState(QAbstractState * state) |
This property holds the type of history that this history state records.
The default value of this property isQHistoryState::ShallowHistory.
Access functions:
| HistoryType | historyType() const |
| void | setHistoryType(HistoryType type) |
Constructs a new shallow history state with the givenparent state.
Constructs a new history state of the giventype, with the givenparent state.
Destroys this history state.
[virtual protected]bool QHistoryState::event(QEvent * e)Reimplemented fromQObject::event().
[virtual protected]void QHistoryState::onEntry(QEvent * event)Reimplemented fromQAbstractState::onEntry().
[virtual protected]void QHistoryState::onExit(QEvent * event)Reimplemented fromQAbstractState::onExit().
© 2016 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 theGNU 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.