QFinalState Class

The QFinalState class provides a final state. More...

Header: #include <QFinalState>
qmake: QT += core
Since: Qt 4.6
Inherits: QAbstractState

This class was introduced in Qt 4.6.

Public Functions

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

Reimplemented Protected Functions

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

Detailed Description

A final state is used to communicate that (part of) a QStateMachine has finished its work. When a final top-level state is entered, the state machine's finished() signal is emitted. In general, when a final substate (a child of a QState) is entered, the parent state's finished() signal is emitted. QFinalState is part of The State Machine Framework.

To use a final state, you create a QFinalState object and add a transition to it from another state. Example:

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

See also QState::finished().

Member Function Documentation

QFinalState::QFinalState(QState *parent = nullptr)

Constructs a new QFinalState object with the given parent state.

[virtual] QFinalState::~QFinalState()

Destroys this final state.

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

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

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

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

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

Reimplements: QAbstractState::onExit(QEvent *event).

© The Qt Company Ltd
Licensed under the GNU Free Documentation License, Version 1.3.
https://doc.qt.io/qt-5.14/qfinalstate.html