The QSignalTransition class provides a transition based on a Qt signal. 更多...
头: | #include <QSignalTransition> |
CMake: |
find_package(Qt6 REQUIRED COMPONENTS StateMachine)
target_link_libraries(mytarget PRIVATE Qt6::StateMachine) |
qmake: | QT += statemachine |
继承: | QAbstractTransition |
QSignalTransition (QState * sourceState = nullptr) | |
QSignalTransition (const QObject * sender , const char * signal , QState * sourceState = nullptr) | |
QSignalTransition (const QObject * sender , PointerToMemberFunction signal , QState * sourceState = nullptr) | |
virtual | ~QSignalTransition () |
QBindable<const QObject *> | bindableSenderObject () |
QBindable<QByteArray> | bindableSignal () |
const QObject * | senderObject () const |
void | setSenderObject (const QObject * sender ) |
void | setSignal (const QByteArray & signal ) |
QByteArray | signal () const |
void | senderObjectChanged () |
void | signalChanged () |
virtual bool | event (QEvent * e ) override |
virtual bool | eventTest (QEvent * event ) override |
virtual void | onTransition (QEvent * event ) override |
通常,将使用重载 QState::addTransition () that takes a sender and signal as arguments, rather than creating QSignalTransition objects directly. QSignalTransition is part of Qt State Machine Framework .
You can subclass QSignalTransition and reimplement eventTest () to make a signal transition conditional; the event object passed to eventTest () 将是 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);
[bindable]
senderObject
: const
QObject
*
注意: 此特性支持 QProperty 绑定。
This property holds the sender object that this signal transition is associated with
[bindable]
signal
:
QByteArray
注意: 此特性支持 QProperty 绑定。
This property holds the signal that this signal transition is associated with
构造新的信号过渡采用给定 sourceState .
Constructs a new signal transition associated with the given signal 为给定 sender ,和采用给定 sourceState .
这是重载函数。
Constructs a new signal transition associated with the given signal 为给定 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.
[virtual noexcept]
QSignalTransition::
~QSignalTransition
()
销毁此信号过渡。
[override virtual protected]
bool
QSignalTransition::
event
(
QEvent
*
e
)
重实现: QAbstractTransition::event (QEvent *e).
[override virtual protected]
bool
QSignalTransition::
eventTest
(
QEvent
*
event
)
重实现: QAbstractTransition::eventTest (QEvent *event).
默认实现返回
true
若
event
是
QStateMachine::SignalEvent
object and the event's sender and signal index match this transition, and returns
false
否则。
[override virtual protected]
void
QSignalTransition::
onTransition
(
QEvent
*
event
)
重实现: QAbstractTransition::onTransition (QEvent *event).
Returns the sender object associated with this signal transition.
注意: Getter function for property senderObject.
另请参阅 setSenderObject ().
[private signal]
void
QSignalTransition::
senderObjectChanged
()
此信号发射当 senderObject 特性改变。
注意: 这是私有信号。它可以用于信号连接,但不能由用户发射。
注意: 通知程序信号对于特性 senderObject .
另请参阅 QSignalTransition::senderObject .
设置 sender object associated with this signal transition.
注意: setter 函数对于特性 senderObject .
另请参阅 senderObject ().
设置 signal associated with this signal transition.
注意: setter 函数对于特性 signal .
另请参阅 signal ().
Returns the signal associated with this signal transition.
注意: Getter function for property signal.
另请参阅 setSignal ().
[private signal]
void
QSignalTransition::
signalChanged
()
此信号被发射,当信号特性改变时。
注意: 这是私有信号。它可以用于信号连接,但不能由用户发射。
注意: 通知程序信号对于特性 signal .
另请参阅 QSignalTransition::signal .