QFinalState 类

QFinalState 类提供最终状态。 更多...

头: #include <QFinalState>
CMake: find_package(Qt6 COMPONENTS StateMachine REQUIRED)
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:: QFinalState ( QState * parent = nullptr)

构造新的 QFinalState 对象采用给定 parent 状态。

[虚拟] 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).