Home

QtActionState Class Reference
[QtCore module]

The QtActionState class provides an action-based state. More...

 #include <QtActionState>

Inherits QtAbstractState.

Inherited by QtFinalState and QtState.

Public Types

Public Functions

Additional Inherited Members


Detailed Description

The QtActionState class provides an action-based state.

QtActionState executes state actions when the state is entered and exited. QtActionState is part of The State Machine Framework.

You can add actions to a state with the addEntryAction() and addExitAction() functions. The state executes the actions when the state is entered and exited, respectively.

Built-in actions are provided for setting properties and invoking methods of QObjects. The setPropertyOnEntry() and setPropertyOnExit() functions are used for defining property assignments that should be performed when a state is entered and exited, respectively.

 QLabel label;
 QtStateMachine machine;
 QtState *s1 = new QtState();
 s1->setPropertyOnEntry(&label, "text"; "Entered state s1");
 machine.addState(s1);

The invokeMethodOnEntry() and invokeMethodOnExit() functions are used for defining method invocations that should be performed when a state is entered and exited, respectively.

 QtState *s2 = new QtState();
 s2->invokeMethodOnEntry(&label, "showMaximized");
 machine.addState(s2);

See also QtStateAction.


Member Type Documentation

enum QtActionState::RestorePolicy

This enum specifies the restore policy type for a state. The restore policy takes effect when the machine enters a state which has entry actions of the type QtStateSetPropertyAction. If the restore policy of the state is set to RestoreProperties, the state machine will save the value of the property before the QtStateSetPropertyAction is executed.

Later, when the machine either enters a state which has its restore policy set to DoNotRestoreProperties or when it enters a state which does not set a value for the given property, the property will automatically be restored to its initial value. The state machine will only detect which properties are being set if they are being set using a QtStateSetPropertyAction object set as entry action on a state.

Only one initial value will be saved for any given property. If a value for a property has already been saved by the state machine, it will not be overwritten until the property has been successfully restored. Once the property has been restored, the state machine will clear the initial value until it enters a new state which sets the property and which has RestoreProperties as its restore policy.

ConstantValueDescription
QtActionState::GlobalRestorePolicy0The restore policy for the state should be retrieved using QtStateMachine::globalRestorePolicy()
QtActionState::DoNotRestoreProperties1The state machine should not save the initial values of properties set in the state and restore them later.
QtActionState::RestoreProperties2The state machine should save the initial values of properties set in the state and restore them later.

See also setRestorePolicy(), restorePolicy(), addEntryAction(), and setPropertyOnEntry().


Member Function Documentation

QtActionState::QtActionState ( QtState * parent = 0 )

Constructs a new action state with the given parent state.

QtActionState::~QtActionState ()

Destroys this action state.

void QtActionState::addEntryAction ( QtStateAction * action )

Adds the given action to this state. The action will be executed when this state is entered. The state takes ownership of the action.

See also addExitAction().

void QtActionState::addExitAction ( QtStateAction * action )

Adds the given action to this state. The action will be executed when this state is exited. The state takes ownership of the action.

See also addEntryAction().

void QtActionState::invokeMethodOnEntry ( QObject * object, const char * method, const QList<QVariant> & arguments = QList<QVariant> () )

Instructs this state to invoke the given method of the given object with the given arguments when the state is entered. This function will create an object of QtStateInvokeMethodAction and add it to the entry actions of the state.

See also invokeMethodOnExit(), setPropertyOnEntry(), and addEntryAction().

void QtActionState::invokeMethodOnExit ( QObject * object, const char * method, const QList<QVariant> & arguments = QList<QVariant> () )

Instructs this state to invoke the given method of the given object with the given arguments when the state is exited. This function will create an object of QtStateInvokeMethodAction and add it to the exit actions of the state.

See also invokeMethodOnEntry(), setPropertyOnExit(), and addExitAction().

RestorePolicy QtActionState::restorePolicy () const

Returns the restore policy for this state.

See also setRestorePolicy().

void QtActionState::setPropertyOnEntry ( QObject * object, const char * name, const QVariant & value )

Instructs this state to set the property with the given name of the given object to the given value when the state is entered. This function will create an object of QtStateSetPropertyAction and add it to the entry actions of the state.

See also setPropertyOnExit(), invokeMethodOnEntry(), and addEntryAction().

void QtActionState::setPropertyOnExit ( QObject * object, const char * name, const QVariant & value )

Instructs this state to set the property with the given name of the given object to the given value when the state is exited. This function will create an object of QtStateSetPropertyAction and add it to the exit actions of the state.

See also setPropertyOnEntry(), invokeMethodOnExit(), and addExitAction().

void QtActionState::setRestorePolicy ( RestorePolicy restorePolicy )

Sets the restore policy of this state to restorePolicy.

The default restore policy is QtActionState::GlobalRestorePolicy.

See also restorePolicy().


Copyright © 2009 Nokia Trademarks
Qt Solutions