|  | Home · All Classes · Modules

# QEventTransition Class Reference
[QtCore module]

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

Inherits QAbstractTransition.

Inherited by QKeyEventTransition and QMouseEventTransition.

### Methods

- __init__ (self, QState sourceState = None)
- __init__ (self, QObject object, QEvent.Type type, QState sourceState = None)
- bool event (self, QEvent e)
- QObject eventSource (self)
- bool eventTest (self, QEvent event)
- QEvent.Type eventType (self)
- onTransition (self, QEvent event)
- setEventSource (self, QObject object)
- setEventType (self, QEvent.Type type)

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

## Method Documentation

### QEventTransition.__init__ (self, QState sourceState = None)

The sourceState argument, if not None, causes self to be owned by Qt instead of PyQt.

Constructs a new QEventTransition object with the given sourceState.

### QEventTransition.__init__ (self, QObject object, QEvent.Type type, QState sourceState = None)

The sourceState argument, if not None, causes self to be owned by Qt instead of PyQt.

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

### bool QEventTransition.event (self, QEvent e)

Reimplemented from QObject.event().

### QObject QEventTransition.eventSource (self)

### bool QEventTransition.eventTest (self, QEvent event)

Reimplemented from QAbstractTransition.eventTest().

### QEvent.Type QEventTransition.eventType (self)

### QEventTransition.onTransition (self, QEvent event)

Reimplemented from QAbstractTransition.onTransition().

### QEventTransition.setEventSource (self, QObject object)

### QEventTransition.setEventType (self, QEvent.Type type)