State QML Type
为StateMachine 提供通用状态。更多
Import Statement: | import QtQml.StateMachine 6.9 |
Inherits: | |
Inherited By: |
属性
- childMode : enumeration
- errorState : QAbstractState
- initialState : QAbstractState
信号
- finished()
详细说明
状态对象可以有子状态,也可以过渡到其他状态。状态是Qt State Machine QML API的一部分
有子状态的状态
childMode 属性决定如何处理子状态。对于非平行状态组,必须使用initialState 属性来设置初始状态。子状态是互斥状态,当父状态成为转换目标时,状态机需要知道进入哪个子状态。
当进入最终子状态(FinalState )时,状态会发出State::finished() 信号。
errorState 设置状态的错误状态。错误状态是状态机在试图进入状态时检测到错误(如没有设置初始状态)而过渡到的状态。
示例用法
import QtQuick import QtQml.StateMachine as DSM Rectangle { DSM.StateMachine { id: stateMachine initialState: state running: true DSM.State { id: state } } }
另请参阅 StateMachine 和FinalState 。
属性文档
childMode : enumeration |
此状态的子模式
此属性的默认值是QState.ExclusiveStates。
该枚举指定如何处理状态的子状态:
- QState.ExclusiveStates 子状态互斥,必须通过设置initialState 属性来设置初始状态。
- QState.ParallelStates 子状态是并行的。进入父状态时,所有子状态都会并行进入。
errorState : QAbstractState |
此状态的错误状态。
initialState : QAbstractState |
该状态的初始状态(子状态之一)。
信号文档
finished() |
当进入此状态的最终子状态时,会发出此信号。
注: 相应的处理程序是onFinished
。
另请参见 QAbstractState::active,QAbstractState::entered, 和QAbstractState::exited 。
© 2025 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.