Home

QtState Class Reference
[QtCore module]

The QtState class provides a general-purpose state for QtStateMachine. More...

 #include <QtState>

Inherits QtActionState.

This class was introduced in qtstatemachine 4.6.

Public Types

Public Functions

Additional Inherited Members


Detailed Description

The QtState class provides a general-purpose state for QtStateMachine.

QtState objects can have child states, and can have transitions to other states. QtState is part of The State Machine Framework.

The addTransition() function adds a transition. The removeTransition() function removes a transition.

States with Child States

For non-parallel state groups, the setInitialState() function must be called to set the initial state. The child states are mutually exclusive states, and the state machine needs to know which child state to enter when the parent state is the target of a transition.

The addHistoryState() function adds a history state.

The addFinishedTransition() function creates and adds a transition that's triggered when a final child state is entered.

The setErrorState() sets the state's error state. The error state is the state that the state machine will transition to if an error is detected when attempting to enter the state (e.g. because no initial state has been set).


Member Type Documentation

enum QtState::HistoryType

This enum specifies the type of history that a QtHistoryState records.

ConstantValueDescription
QtState::ShallowHistory0Only 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.
QtState::DeepHistory1Nested 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.

enum QtState::Type

This enum specifies the type of a state.

ConstantValueDescription
QtState::Normal0A normal state. If the state has no child states, it is an atomic state; otherwise, the child states are mutually exclusive and an initial state must be set by calling QtState::setInitialState().
QtState::ParallelGroup1The state is a parallel group state. When a parallel group state is entered, all its child states are entered in parallel.


Member Function Documentation

QtState::QtState ( QtState * parent = 0 )

Constructs a new state with the given parent state.

QtState::QtState ( Type type, QtState * parent = 0 )

Constructs a new state of the given type with the given parent state.

QtState::~QtState ()

Destroys this state.

QtStateFinishedTransition * QtState::addFinishedTransition ( QtAbstractState * target )

Adds a transition that's triggered by the finished event of this state, and returns the new QtStateFinishedTransition object. The transition has the given target state.

See also QtStateFinishedEvent.

QtHistoryState * QtState::addHistoryState ( HistoryType type = ShallowHistory )

Creates a history state of the given type for this state and returns the new state. The history state becomes a child of this state.

void QtState::addTransition ( QtAbstractTransition * transition )

Adds the given transition. The transition has this state as the source. This state takes ownership of the transition.

QtSignalTransition * QtState::addTransition ( QObject * sender, const char * signal, QtAbstractState * target )

This is an overloaded member function, provided for convenience.

Adds a transition associated with the given signal of the given sender object, and returns the new QtSignalTransition object. The transition has this state as the source, and the given target as the target state.

QtAbstractTransition * QtState::addTransition ( QtAbstractState * target )

This is an overloaded member function, provided for convenience.

Adds an unconditional transition from this state to the given target state, and returns then new transition object.

QtAbstractState * QtState::errorState () const

Returns this state group's error state.

See also QtStateMachine::errorState() and QtStateMachine::setErrorState().

QtAbstractState * QtState::initialState () const

Returns this state's initial state, or 0 if the state has no initial state.

See also setInitialState().

void QtState::removeTransition ( QtAbstractTransition * transition )

Removes the given transition from this state. The state releases ownership of the transition.

See also addTransition().

void QtState::setErrorState ( QtAbstractState * state )

Sets this state's error state to be the given state. If the error state is not set, or if it is set to 0, the state will inherit its parent's error state recursively.

See also QtStateMachine::setErrorState() and QtStateMachine::errorState().

void QtState::setInitialState ( QtAbstractState * state )

Sets this state's initial state to be the given state. state has to be a child of this state.

See also initialState().

QList<QtAbstractTransition *> QtState::transitions () const

Returns the list of transitions from this state, or an empty list if there are no transitions from this state.

See also addTransition() and removeTransition().


Copyright © 2009 Nokia Trademarks
Qt Solutions