本页内容

FinalState QML Type

提供最终状态。更多...

Import Statement: import QtQml.StateMachine 6.12
Inherits:

QAbstractState

详细说明

最终状态用于表示StateMachine (或其部分)已完成工作。当进入最终顶级状态时,状态机的finished()信号会被触发。通常,当进入最终子状态(State的子状态)时,父状态的finished()信号会被触发。 FinalState 是Qt State Machine QML API的一部分

要使用最终状态,需创建一个 FinalState 对象,并从另一个状态向其添加一个过渡。

使用示例

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")
    }
}

另请参阅 StateMachine 和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.