In questa pagina

FinalState QML Type

Fornisce uno stato finale. Altro...

Import Statement: import QtQml.StateMachine 6.12
Inherits:

QAbstractState

Descrizione dettagliata

Uno stato finale viene utilizzato per indicare che (una parte di) una macchina a stati ( StateMachine ) ha terminato il proprio lavoro. Quando si entra in uno stato finale di livello superiore, viene emesso il segnale finished() della macchina a stati. In generale, quando si entra in uno stato secondario finale (figlio di uno Stato), viene emesso il segnale finished() dello stato padre. FinalState fa parte dell’API QML di Qt State Machine

Per utilizzare uno stato finale, occorre creare un oggetto `FinalState` e aggiungervi una transizione da un altro stato.

Esempio di utilizzo

import QtQuick
import QtQml.StateMachine as DSM

Rectangle {
    DSM.StateMachine {
        id: stateMachine
        initialState: state
        running: true
        DSM.State {
            id: state
            DSM.TimeoutTransition {
                targetState: finalState
                timeout: 200
            }
        }
        DSM.FinalState {
            id: finalState
        }
        onFinished: console.log("state finished")
    }
}

Vedi anche StateMachine e State.

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