![]() |
Home |
The QtSignalTransition class provides a transition based on a Qt signal. More...
#include <QtSignalTransition>
Inherits QtTransition.
The QtSignalTransition class provides a transition based on a Qt signal.
Typically you would use the overload of QtState::addTransition() that takes a sender and signal as arguments, rather than creating QtSignalTransition objects directly. QtSignalTransition is part of The State Machine Framework.
You can subclass QtSignalTransition and reimplement testCondition() to make a signal transition conditional; the event object passed to testCondition() will be a QtSignalEvent object. Example:
class CheckedTransition : public QtSignalTransition
{
public:
CheckedTransition(QCheckBox *check)
: QtSignalTransition(check, SIGNAL(stateChanged(int))) {}
protected:
bool testCondition(QEvent *e) const {
QtSignalEvent *se = static_cast<QtSignalEvent*>(e);
return (se->arguments().at(0).toInt() == Qt::Checked)
&& QtSignalTransition::testCondition(e);
}
};
...
QCheckBox *check = new QCheckBox();
check->setTristate(true);
QtState *s1 = new QtState();
QtState *s2 = new QtState();
s1->addTransition(new CheckedTransition(check), s2);
Constructs a new signal transition associated with the given signal of the given sender.
See also QtState::addTransition().
Destroys this signal transition.
| Copyright © 2009 Nokia | Trademarks | Qt Solutions |