QFinalState 类提供最终状态。 更多...
头: | #include <QFinalState> |
CMake: |
find_package(Qt6 REQUIRED COMPONENTS StateMachine)
target_link_libraries(mytarget PRIVATE Qt6::StateMachine) |
qmake: | QT += statemachine |
继承: | QAbstractState |
QFinalState (QState * parent = nullptr) | |
virtual | ~QFinalState () |
virtual bool | event (QEvent * e ) override |
virtual void | onEntry (QEvent * event ) override |
virtual void | onExit (QEvent * event ) override |
最终状态用于传达 (属于) QStateMachine 已完成其工作。当进入最终顶层状态时,状态机的 finished () 信号发射。一般而言,当最终子状态 (子级化的 QState ) 进入,父级状态的 finished () 信号发射。QFinalState 属于 Qt State Machine Framework .
要使用最终状态,创建 QFinalState 对象并从另一状态向其添加过渡。范例:
QPushButton button; QStateMachine machine; QState *s1 = new QState(); QFinalState *s2 = new QFinalState(); s1->addTransition(&button, SIGNAL(clicked()), s2); machine.addState(s1); machine.addState(s2); QObject::connect(&machine, SIGNAL(finished()), QApplication::instance(), SLOT(quit())); machine.setInitialState(s1); machine.start();
另请参阅 QState::finished ().
构造新的 QFinalState 对象采用给定 parent 状态。
[virtual noexcept]
QFinalState::
~QFinalState
()
销毁此最终状态。
[override virtual protected]
bool
QFinalState::
event
(
QEvent
*
e
)
重实现: QAbstractState::event (QEvent *e).
[override virtual protected]
void
QFinalState::
onEntry
(
QEvent
*
event
)
重实现: QAbstractState::onEntry (QEvent *event).
[override virtual protected]
void
QFinalState::
onExit
(
QEvent
*
event
)
重实现: QAbstractState::onExit (QEvent *event).