Home

QtHistoryState Class Reference
[QtCore module]

The QtHistoryState class provides a means of returning to a previously active substate. More...

 #include <QtHistoryState>

Inherits QtAbstractState.

This class was introduced in qtstatemachine 4.6.

Public Functions

Additional Inherited Members


Detailed Description

The QtHistoryState 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. QtHistoryState is part of The State Machine Framework.

Use QtState::addHistoryState() to construct a history state. Use the setDefaultState() function to set the state that should be entered if the parent state has never been entered. Example:

 QtStateMachine machine;

 QtState *s1 = new QtState();
 QtState *s11 = new QtState(s1);
 QtState *s12 = new QtState(s1);

 QtState *s1h = s1->addHistoryState();
 s1h->setDefaultState(s11);

 machine.addState(s1);

 QtState *s2 = new QtState();
 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);

Member Function Documentation

QtHistoryState::~QtHistoryState ()

Destroys this history state.

QtAbstractState * QtHistoryState::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.

See also setDefaultState().

void QtHistoryState::setDefaultState ( QtAbstractState * state )

Sets this history state's default state to be the given state. state must be a sibling of this history state.

See also defaultState().


Copyright © 2009 Nokia Trademarks
Qt Solutions