En esta página

QFinalState Class

La clase QFinalState proporciona un estado final. Más información...

Encabezado: #include <QFinalState>
CMake: find_package(Qt6 REQUIRED COMPONENTS StateMachine)
target_link_libraries(mytarget PRIVATE Qt6::StateMachine)
qmake: QT += statemachine
Heredado de: 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 indicar que (parte de) un « QStateMachine » ha finalizado 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, al entrar en un subestado final (hijo de un ` QState`), se emite la señal ` finished()` del estado padre. `QFinalState` forma parte del marco de trabajo «Qt State Machine ».

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 de miembro

QFinalState::QFinalState(QState *parent = nullptr)

Crea un nuevo objeto `QFinalState` con el estado ` parent ` indicado.

[virtual noexcept] QFinalState::~QFinalState()

Elimina 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.