Home

QtEventTransition Class Reference
[QtCore module]

The QtEventTransition class provides a QObject-specific transition for Qt events. More...

 #include <QtEventTransition>

Inherits QtTransition.

This class was introduced in qtstatemachine 4.6.

Properties

Public Functions

Protected Functions

Additional Inherited Members


Detailed Description

The QtEventTransition class provides a QObject-specific transition for Qt events.

A QtEventTransition object binds an event to a particular QObject. QtEventTransition is part of The State Machine Framework.

Example:

 QPushButton *button = ...;
 QtState *s1 = ...;
 QtState *s2 = ...;
 // If in s1 and the button receives an Enter event, transition to s2
 QtEventTransition *enterTransition = new QtEventTransition(button, QEvent::Enter);
 enterTransition->setTargetState(s2);
 s1->addTransition(enterTransition);
 // If in s2 and the button receives an Exit event, transition back to s1
 QtEventTransition *leaveTransition = new QtEventTransition(button, QEvent::Leave);
 leaveTransition->setTargetState(s1);
 s2->addTransition(leaveTransition);

Subclassing

Many event classes have attributes in addition to the event type itself. The testEventCondition() function can be reimplemented to check attributes of an event instance in order to determine whether the transition should be triggered or not.

See also QtState::addTransition().


Property Documentation

eventType : QEvent::Type

This property holds the type of event that this event transition is associated with.

Access functions:

object : QObject *

This property holds the event source that this event transition is associated with.

Access functions:


Member Function Documentation

QtEventTransition::QtEventTransition ( QtState * sourceState = 0 )

Constructs a new QtEventTransition object with the given sourceState.

QtEventTransition::QtEventTransition ( QObject * object, QEvent::Type type, QtState * sourceState = 0 )

Constructs a new QtEventTransition object associated with events of the given type for the given object, and with the given sourceState.

QtEventTransition::QtEventTransition ( QObject * object, QEvent::Type type, const QList<QtAbstractState *> & targets, QtState * sourceState = 0 )

Constructs a new QtEventTransition object associated with events of the given type for the given object. The transition has the given targets and sourceState.

QtEventTransition::~QtEventTransition ()

Destroys this QObject event transition.

bool QtEventTransition::testEventCondition ( QEvent * event ) const   [virtual protected]

Tests an instance of an event associated with this event transition and returns true if the transition should be taken, otherwise returns false. The type of the given event will be eventType().

Reimplement this function if you have custom conditions associated with the transition. The default implementation always returns true.


Copyright © 2009 Nokia Trademarks
Qt Solutions