Home · All Classes · Modules

QSignalTransition Class Reference
[QtCore module]

The QSignalTransition class provides a transition based on a Qt signal. More...

Inherits QAbstractTransition.

Methods


Detailed Description

The QSignalTransition class provides a transition based on a Qt signal.

Typically you would use the overload of QState.addTransition() that takes a sender and signal as arguments, rather than creating QSignalTransition objects directly. QSignalTransition is part of The State Machine Framework.

You can subclass QSignalTransition and reimplement eventTest() to make a signal transition conditional; the event object passed to eventTest() will be a QStateMachine.SignalEvent object. Example:

 class CheckedTransition : public QSignalTransition
 {
 public:
     CheckedTransition(QCheckBox *check)
         : QSignalTransition(check, SIGNAL(stateChanged(int))) {}
 protected:
     bool eventTest(QEvent *e) {
         if (!QSignalTransition.eventTest(e))
             return false;
         QStateMachine.SignalEvent *se = static_cast<QStateMachine.SignalEvent*>(e);
         return (se->arguments().at(0).toInt() == Qt.Checked);
     }
 };

 ...

 QCheckBox *check = new QCheckBox();
 check->setTristate(true);

 QState *s1 = new QState();
 QState *s2 = new QState();
 CheckedTransition *t1 = new CheckedTransition(check);
 t1->setTargetState(s2);
 s1->addTransition(t1);

Method Documentation

QSignalTransition.__init__ (self, QState sourceState = None)

Constructs a new signal transition with the given sourceState.

QSignalTransition.__init__ (self, QObject sender, SIGNAL() signal, QState sourceState = None)

Constructs a new signal transition associated with the given signal of the given sender, and with the given sourceState.

QSignalTransition.__init__ (self, signal signal, QState sourceState = None)

bool QSignalTransition.event (self, QEvent e)

Reimplemented from QObject.event().

bool QSignalTransition.eventTest (self, QEvent event)

Reimplemented from QAbstractTransition.eventTest().

The default implementation returns true if the event is a QStateMachine.SignalEvent object and the event's sender and signal index match this transition, and returns false otherwise.

QSignalTransition.onTransition (self, QEvent event)

Reimplemented from QAbstractTransition.onTransition().

QObject QSignalTransition.senderObject (self)

QSignalTransition.setSenderObject (self, QObject sender)

QSignalTransition.setSignal (self, QByteArray signal)

QByteArray QSignalTransition.signal (self)


PyQt 4.10.1 for MacOSCopyright © Riverbank Computing Ltd and Nokia 2012Qt 4.8.4