Qt 4.8: QAbstractTransition Class Reference

Qt Reference Documentation

# QAbstractTransition Class Reference

The QAbstractTransition class is the base class of transitions between QAbstractState objects. More...

     #include <QAbstractTransition>

Inherits: QObject.

Inherited by: QEventTransition and QSignalTransition.

This class was introduced in Qt 4.6.

- List of all members, including inherited members

## Properties

- sourceState : QState * const
- targetState : QAbstractState *
- targetStates : QList<QAbstractState *>

- 1 property inherited from QObject

## Public Functions

| QAbstractTransition ( QState * sourceState = 0 )
virtual | ~QAbstractTransition ()
void | addAnimation ( QAbstractAnimation * animation )
QList<QAbstractAnimation *> | animations () const
QStateMachine * | machine () const
void | removeAnimation ( QAbstractAnimation * animation )
void | setTargetState ( QAbstractState * target )
void | setTargetStates ( const QList<QAbstractState *> & targets )
QState * | sourceState () const
QAbstractState * | targetState () const
QList<QAbstractState *> | targetStates () const

- 29 public functions inherited from QObject

## Signals

void | triggered ()

- 1 signal inherited from QObject

## Protected Functions

virtual bool | eventTest ( QEvent * event ) = 0
virtual void | onTransition ( QEvent * event ) = 0

## Reimplemented Protected Functions

virtual bool | event ( QEvent * e )

- 8 protected functions inherited from QObject

### Additional Inherited Members

- 1 public slot inherited from QObject
- 7 static public members inherited from QObject

## Detailed Description

The QAbstractTransition class is the base class of transitions between QAbstractState objects.

The QAbstractTransition class is the abstract base class of transitions between states (QAbstractState objects) of a QStateMachine. QAbstractTransition is part of The State Machine Framework.

The sourceState() function returns the source of the transition. The targetStates() function returns the targets of the transition. The machine() function returns the state machine that the transition is part of.

The triggered() signal is emitted when the transition has been triggered.

Transitions can cause animations to be played. Use the addAnimation() function to add an animation to the transition.

### Subclassing

The eventTest() function is called by the state machine to determine whether an event should trigger the transition. In your reimplementation you typically check the event type and cast the event object to the proper type, and check that one or more properties of the event meet your criteria.

The onTransition() function is called when the transition is triggered; reimplement this function to perform custom processing for the transition.

## Property Documentation

### sourceState : QState * const

This property holds the source state (parent) of this transition.

Access functions:

QState * | sourceState () const

### targetState : QAbstractState *

This property holds the target state of this transition.

If a transition has no target state, the transition may still be triggered, but this will not cause the state machine's configuration to change (i.e. the current state will not be exited and re-entered).

Access functions:

QAbstractState * | targetState () const
void | setTargetState ( QAbstractState * target )

### targetStates : QList<QAbstractState *>

This property holds the target states of this transition.

If multiple states are specified, all must be descendants of the same parallel group state.

Access functions:

QList<QAbstractState *> | targetStates () const
void | setTargetStates ( const QList<QAbstractState *> & targets )

## Member Function Documentation

### QAbstractTransition::QAbstractTransition ( QState * sourceState = 0 )

Constructs a new QAbstractTransition object with the given sourceState.

### QAbstractTransition::~QAbstractTransition ()`[virtual]`

Destroys this transition.

### void QAbstractTransition::addAnimation ( QAbstractAnimation * animation )

Adds the given animation to this transition. The transition does not take ownership of the animation.

See also removeAnimation() and animations().

### QList<QAbstractAnimation *> QAbstractTransition::animations () const

Returns the list of animations associated with this transition, or an empty list if it has no animations.

See also addAnimation().

### bool QAbstractTransition::event ( QEvent * e )`[virtual protected]`

Reimplemented from QObject::event().

### bool QAbstractTransition::eventTest ( QEvent * event )`[pure virtual protected]`

This function is called to determine whether the given event should cause this transition to trigger. Reimplement this function and return true if the event should trigger the transition, otherwise return false.

### QStateMachine * QAbstractTransition::machine () const

Returns the state machine that this transition is part of, or 0 if the transition is not part of a state machine.

### void QAbstractTransition::onTransition ( QEvent * event )`[pure virtual protected]`

This function is called when the transition is triggered. The given event is what caused the transition to trigger. Reimplement this function to perform custom processing when the transition is triggered.

### void QAbstractTransition::removeAnimation ( QAbstractAnimation * animation )

Removes the given animation from this transition.

See also addAnimation().

### void QAbstractTransition::triggered ()`[signal]`

This signal is emitted when the transition has been triggered (after onTransition() has been called).