Home

QtState Class Reference
[QtCore module]

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

 #include <QtState>

Inherits QtActionState.

Inherited by QtAnimationState.

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

QtAnimationState * QtState::addAnimatedTransition ( QtAbstractTransition * transition, QtAbstractState * targetState, QtAbstractAnimation * animation = 0 )

Adds an animated transition from the current state to targetState.

The animated transition has an intermediate QtAnimationState which plays animation before entering targetState. This QtAnimationState will be entered when transition is taken by the state machine. When the animation has finished playing, the targetState will be entered.

The new QtAnimationState object will become a child of targetState's parent state.

 QPushButton button;
 QtPropertyAnimation animation(&button, "geometry");
 animation.setEndValue(QRect(100, 100, 400, 400));

 QtStateMachine machine;

 QtState *s1 = new QtState();
 QtState *s2 = new QtState();

 QtTransition *transition = new QtTransition(MyEventType);
 s1->addAnimatedTransition(transition, s2, &animation);

The function returns the new QtAnimationState. This state can be used if you want to add additional transitions into or out from the animation state, and if you want to add additional animations.

See also QtAnimationState.

QtAnimationState * QtState::addAnimatedTransition ( const QObject * sender, const char * signal, QtAbstractState * targetState, QtAbstractAnimation * animation = 0 )

This is an overloaded member function, provided for convenience.

Adds an animated transition from the current state to targetState for animation.

This function creates a QtSignalTransition for the sender and signal, and calls addAnimatedTransition() with this transition object.

void QtState::addFinishedTransition ( QtAbstractState * target )

Adds a transition that's triggered by the finished event of this state, and that 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, QtAbstractState * target )

Adds the given transition. The transition has this state as the source, and the given target as the target state.

See also removeTransition().

void QtState::addTransition ( QtAbstractTransition * transition, const QList<QtAbstractState *> & targets )

This is an overloaded member function, provided for convenience.

Adds the given transition. The transition has this state as the source, and the given targets as the target states.

void QtState::addTransition ( const 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. The transition has this state as the source, and the given target as the target state.

void QtState::addTransition ( QtAbstractTransition * transition )

This is an overloaded member function, provided for convenience.

Adds the given transition. The transition has this state as the source, and has no target.

void 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.

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


Copyright © 2009 Nokia Trademarks
Qt Solutions