The QSignalTransition class provides a transition based on a Qt signal. More...
#include <QSignalTransition>
Inherits: QAbstractTransition.
This class was introduced in Qt 4.6.
QSignalTransition ( QState * sourceState = 0 ) | |
QSignalTransition ( QObject * sender, const char * signal, QState * sourceState = 0 ) | |
~QSignalTransition () | |
QObject * | senderObject () const |
void | setSenderObject ( QObject * sender ) |
void | setSignal ( const QByteArray & signal ) |
QByteArray | signal () const |
virtual bool | event ( QEvent * e ) |
virtual bool | eventTest ( QEvent * event ) |
virtual void | onTransition ( QEvent * event ) |
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);
This property holds the sender object that this signal transition is associated with.
Access functions:
QObject * | senderObject () const |
void | setSenderObject ( QObject * sender ) |
This property holds the signal that this signal transition is associated with.
Access functions:
QByteArray | signal () const |
void | setSignal ( const QByteArray & signal ) |
Constructs a new signal transition with the given sourceState.
Constructs a new signal transition associated with the given signal of the given sender, and with the given sourceState.
Destroys this signal transition.
Reimplemented from QObject::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.
Reimplemented from QAbstractTransition::onTransition().
© 2008-2011 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide.
All other trademarks are property of their respective owners. Privacy Policy
Licensees holding valid Qt Commercial licenses may use this document in accordance with the Qt Commercial License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Nokia.
Alternatively, this document may be used under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.