QFinalState Class
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 框架的一部分。
要使用最终状态,需创建一个 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)
使用给定的parent 状态构建一个新的QFinalState对象。
[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)。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.