QEventTransition Class

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

Header: #include <QEventTransition>
qmake: QT += core
Since: Qt 4.6
Inherits: QAbstractTransition

Properties

Public Functions

QEventTransition(QState *sourceState = nullptr)
QEventTransition(QObject *object, QEvent::Type type, QState *sourceState = nullptr)
virtual ~QEventTransition()
QObject * eventSource() const
QEvent::Type eventType() const
void setEventSource(QObject *object)
void setEventType(QEvent::Type type)

Reimplemented Protected Functions

virtual bool event(QEvent *e) override
virtual bool eventTest(QEvent *event) override
virtual void onTransition(QEvent *event) override

Additional Inherited Members

Detailed Description

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

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

Example:

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

Subclassing

When reimplementing the eventTest() function, you should first call the base implementation to verify that the event is a QStateMachine::WrappedEvent for the proper object and event type. You may then cast the event to a QStateMachine::WrappedEvent and get the original event by calling QStateMachine::WrappedEvent::event(), and perform additional checks on that object.

See also QState::addTransition().

Property Documentation

eventSource : QObject*

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

Access functions:

QObject * eventSource() const
void setEventSource(QObject *object)

eventType : QEvent::Type

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

Access functions:

QEvent::Type eventType() const
void setEventType(QEvent::Type type)

Member Function Documentation

QEventTransition::QEventTransition(QState *sourceState = nullptr)

Constructs a new QEventTransition object with the given sourceState.

QEventTransition::QEventTransition(QObject *object, QEvent::Type type, QState *sourceState = nullptr)

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

[virtual] QEventTransition::~QEventTransition()

Destroys this QObject event transition.

[override virtual protected] bool QEventTransition::event(QEvent *e)

Reimplemented from QAbstractTransition::event().

QObject *QEventTransition::eventSource() const

Returns the event source associated with this event transition.

Note: Getter function for property eventSource.

See also setEventSource().

[override virtual protected] bool QEventTransition::eventTest(QEvent *event)

Reimplemented from QAbstractTransition::eventTest().

QEvent::Type QEventTransition::eventType() const

Returns the event type that this event transition is associated with.

Note: Getter function for property eventType.

See also setEventType().

[override virtual protected] void QEventTransition::onTransition(QEvent *event)

Reimplemented from QAbstractTransition::onTransition().

void QEventTransition::setEventSource(QObject *object)

Sets the event source associated with this event transition to be the given object.

Note: Setter function for property eventSource.

See also eventSource().

void QEventTransition::setEventType(QEvent::Type type)

Sets the event type that this event transition is associated with.

Note: Setter function for property eventType.

See also eventType().

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support