QSignalTransition Class
The QSignalTransition class provides a transition based on a Qt signal. 更多...
头文件: | #include <QSignalTransition> |
qmake: | QT += core |
开始支持版本: | Qt 4.6 |
基类: | QAbstractTransition |
属性
- senderObject : QObject *
- signal : QByteArray
- 4 个属性继承自 QAbstractTransition
- 1 个属性继承自 QObject
公有函数
QSignalTransition(QState *sourceState = Q_NULLPTR) | |
QSignalTransition(const QObject *sender, const char *signal, QState *sourceState = Q_NULLPTR) | |
QSignalTransition(const QObject *sender, PointerToMemberFunction signal, QState *sourceState = Q_NULLPTR) | |
~QSignalTransition() | |
QObject * | senderObject() const |
void | setSenderObject(const QObject *sender) |
void | setSignal(const QByteArray &signal) |
QByteArray | signal() const |
- 11 个公有函数继承自 QAbstractTransition
- 32 个公有函数继承自 QObject
信号
void | senderObjectChanged() |
void | signalChanged() |
- 3 个信号继承自 QAbstractTransition
- 2 个信号继承自 QObject
重新实现的受保护函数
virtual bool | event(QEvent *e) |
virtual bool | eventTest(QEvent *event) |
virtual void | onTransition(QEvent *event) |
- 3 个受保护的函数继承自 QAbstractTransition
- 9 个受保护的函数继承自 QObject
其他继承的成员
- 1 个公有槽函数继承自 QObject
- 11 个静态公有成员继承自 QObject
- 3 个受保护的函数继承自 QAbstractTransition
- 9 个受保护的函数继承自 QObject
详细描述
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);
属性
senderObject : QObject *
This property holds the sender object that this signal transition is associated with
访问函数:
QObject * | senderObject() const |
void | setSenderObject(const QObject *sender) |
Notifier signal:
void | senderObjectChanged() | [see note below] |
Note: This is a private signal. It can be used in signal connections but cannot be emitted by the user.
signal : QByteArray
This property holds the signal that this signal transition is associated with
访问函数:
Notifier signal:
void | signalChanged() | [see note below] |
Note: This is a private signal. It can be used in signal connections but cannot be emitted by the user.
成员函数
QSignalTransition::QSignalTransition(QState *sourceState = Q_NULLPTR)
Constructs a new signal transition with the given sourceState.
QSignalTransition::QSignalTransition(const QObject *sender, const char *signal, QState *sourceState = Q_NULLPTR)
Constructs a new signal transition associated with the given signal of the given sender, and with the given sourceState.
QSignalTransition::QSignalTransition(const QObject *sender, PointerToMemberFunction signal, QState *sourceState = Q_NULLPTR)
This is an overloaded function.
Constructs a new signal transition associated with the given signal of the given sender object and with the given sourceState. This constructor is enabled if the compiler supports delegating constructors, as indicated by the presence of the macro Q_COMPILER_DELEGATING_CONSTRUCTORS.
This function was introduced in Qt 5.7.
QSignalTransition::~QSignalTransition()
Destroys this signal transition.
[virtual protected]
bool QSignalTransition::event(QEvent *e)
Reimplemented from QObject::event().
[virtual protected]
bool QSignalTransition::eventTest(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.
[virtual protected]
void QSignalTransition::onTransition(QEvent *event)
Reimplemented from QAbstractTransition::onTransition().
QObject *QSignalTransition::senderObject() const
Returns the sender object associated with this signal transition.
Note: Getter function for property senderObject.
参见 setSenderObject().
[signal]
void QSignalTransition::senderObjectChanged()
This signal is emitted when the senderObject property is changed.
This function was introduced in Qt 5.4.
Note: This is a private signal. It can be used in signal connections but cannot be emitted by the user.
Note: Notifier signal for property senderObject.
参见 QSignalTransition::senderObject.
void QSignalTransition::setSenderObject(const QObject *sender)
Sets the sender object associated with this signal transition.
Note: Setter function for property senderObject.
参见 senderObject().
void QSignalTransition::setSignal(const QByteArray &signal)
Sets the signal associated with this signal transition.
Note: Setter function for property signal.
参见 signal().
QByteArray QSignalTransition::signal() const
Returns the signal associated with this signal transition.
Note: Getter function for property signal.
参见 setSignal().
[signal]
void QSignalTransition::signalChanged()
This signal is emitted when the signal property is changed.
This function was introduced in Qt 5.4.
Note: This is a private signal. It can be used in signal connections but cannot be emitted by the user.
Note: Notifier signal for property signal.