En esta página

QFinalState Class

La clase QFinalState proporciona un estado final. Más...

Cabecera: #include <QFinalState>
CMake: find_package(Qt6 REQUIRED COMPONENTS StateMachine)
target_link_libraries(mytarget PRIVATE Qt6::StateMachine)
qmake: QT += statemachine
Hereda: QAbstractState

Funciones Públicas

QFinalState(QState *parent = nullptr)
virtual ~QFinalState()

Funciones protegidas reimplementadas

virtual bool event(QEvent *e) override
virtual void onEntry(QEvent *event) override
virtual void onExit(QEvent *event) override

Descripción Detallada

Un estado final se utiliza para comunicar que (parte de) un QStateMachine ha terminado su trabajo. Cuando se entra en un estado final de nivel superior, se emite la señal finished() de la máquina de estados. En general, cuando se entra en un subestado final (un hijo de un QState), se emite la señal finished() del estado padre. QFinalState forma parte de Qt State Machine Framework.

Para utilizar un estado final, se crea un objeto QFinalState y se le añade una transición desde otro estado. Ejemplo:

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();

Véase también QState::finished().

Documentación de las funciones miembro

QFinalState::QFinalState(QState *parent = nullptr)

Construye un nuevo objeto QFinalState con el estado parent dado.

[virtual noexcept] QFinalState::~QFinalState()

Destruye este estado final.

[override virtual protected] bool QFinalState::event(QEvent *e)

Reimplementa: QAbstractState::event(QEvent *e).

[override virtual protected] void QFinalState::onEntry(QEvent *event)

Reimplementa: QAbstractState::onEntry(QEvent *event).

[override virtual protected] void QFinalState::onExit(QEvent *event)

Reimplementa: 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.