QHistoryState 類

The QHistoryState class provides a means of returning to a previously active substate. 更多...

頭: #include <QHistoryState>
qmake: QT += core
Since: Qt 4.6
繼承: QAbstractState

公共類型

enum HistoryType { ShallowHistory, DeepHistory }

特性

公共函數

QHistoryState (QState * parent = Q_NULLPTR)
QHistoryState (HistoryType type , QState * parent = Q_NULLPTR)
~QHistoryState ()
QAbstractState * defaultState () const
QAbstractTransition * defaultTransition () const
HistoryType historyType () const
void setDefaultState (QAbstractState * state )
void setDefaultTransition (QAbstractTransition * transition )
void setHistoryType (HistoryType type )

信號

void defaultStateChanged ()
void defaultTransitionChanged ()
void historyTypeChanged ()

重實現保護函數

virtual bool event (QEvent * e )
virtual void onEntry (QEvent * event )
virtual void onExit (QEvent * event )

額外繼承成員

詳細描述

The QHistoryState 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 or more other child states of the parent state. QHistoryState 屬於 狀態機框架 .

使用 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 特性。

成員類型文檔編製

enum QHistoryState:: 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.

特性文檔編製

defaultState : QAbstractState *

This property holds the default state of this history state

訪問函數:

QAbstractState * defaultState () const
void setDefaultState (QAbstractState * state )

通知程序信號:

void defaultStateChanged () [見下文注意事項]

注意: 這是私有信號。它可以用於信號連接,但不能由用戶發射。

defaultTransition : QAbstractTransition *

This property holds the default transition of this history state

訪問函數:

QAbstractTransition * defaultTransition () const
void setDefaultTransition (QAbstractTransition * transition )

通知程序信號:

void defaultTransitionChanged () [見下文注意事項]

注意: 這是私有信號。它可以用於信號連接,但不能由用戶發射。

historyType : HistoryType

This property holds the type of history that this history state records

此特性的默認值為 QHistoryState::ShallowHistory .

訪問函數:

HistoryType historyType () const
void setHistoryType (HistoryType type )

通知程序信號:

void historyTypeChanged () [見下文注意事項]

注意: 這是私有信號。它可以用於信號連接,但不能由用戶發射。

成員函數文檔編製

QHistoryState:: QHistoryState ( QState * parent = Q_NULLPTR)

Constructs a new shallow history state with the given parent 狀態。

QHistoryState:: QHistoryState ( HistoryType type , QState * parent = Q_NULLPTR)

Constructs a new history state of the given type ,采用給定 parent 狀態。

QHistoryState:: ~QHistoryState ()

Destroys this history state.

QAbstractState *QHistoryState:: defaultState () const

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 函數對於特性 defaultState .

另請參閱 setDefaultState ().

[signal] void QHistoryState:: defaultStateChanged ()

此信號被發射當 defaultState 特性改變。

該函數在 Qt 5.4 引入。

注意: 這是私有信號。它可以用於信號連接,但不能由用戶發射。

注意: 通知程序信號對於特性 defaultState .

另請參閱 QHistoryState::defaultState .

QAbstractTransition *QHistoryState:: defaultTransition () const

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.

該函數在 Qt 5.6 引入。

注意: getter 函數對於特性 defaultTransition .

另請參閱 setDefaultTransition ().

[signal] void QHistoryState:: defaultTransitionChanged ()

此信號被發射當 defaultTransition 特性改變。

該函數在 Qt 5.6 引入。

注意: 這是私有信號。它可以用於信號連接,但不能由用戶發射。

注意: 通知程序信號對於特性 defaultTransition .

另請參閱 QHistoryState::defaultTransition .

[virtual protected] bool QHistoryState:: event ( QEvent * e )

重實現自 QObject::event ().

HistoryType QHistoryState:: historyType () const

Returns the type of history that this history state records.

注意: getter 函數對於特性 historyType .

另請參閱 setHistoryType ().

[signal] void QHistoryState:: historyTypeChanged ()

此信號被發射當 historyType 特性改變。

該函數在 Qt 5.4 引入。

注意: 這是私有信號。它可以用於信號連接,但不能由用戶發射。

注意: 通知程序信號對於特性 historyType .

另請參閱 QHistoryState::historyType .

[virtual protected] void QHistoryState:: onEntry ( QEvent * event )

重實現自 QAbstractState::onEntry ().

[virtual protected] void QHistoryState:: onExit ( QEvent * event )

重實現自 QAbstractState::onExit ().

void QHistoryState:: setDefaultState ( QAbstractState * state )

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 ().

void QHistoryState:: setDefaultTransition ( QAbstractTransition * transition )

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.

該函數在 Qt 5.6 引入。

注意: setter 函數對於特性 defaultTransition .

另請參閱 defaultTransition ().

void QHistoryState:: setHistoryType ( HistoryType type )

設置 type of history that this history state records.

注意: setter 函數對於特性 historyType .

另請參閱 historyType ().