StateGroup QML Type
为非项目类型提供内置状态支持。更多
Import Statement: | import QtQuick |
属性
- state : string
- states : list<State>
- transitions : list<Transition>
详细说明
Item(以及所有派生类型)通过其state 、states 和transitions 属性为状态和转换提供内置支持。StateGroup 提供了一种在其他(非项目派生)类型中使用该支持的简便方法。
MyCustomObject { StateGroup { id: myStateGroup states: State { name: "state1" // ... } transitions: Transition { // ... } } onSomethingHappened: myStateGroup.state = "state1"; }
另请参阅 Qt Quick 状态、过渡和 Qt Qml.
属性文档
state : string |
该属性保存状态组当前状态的名称。
脚本中经常使用该属性在不同状态之间切换。例如
function toggle() { if (button.state == 'On') button.state = 'Off'; else button.state = 'On'; }
如果状态组处于基本状态(即未设置显式状态),state
将是一个空白字符串。同样,通过将状态组的当前状态设置为''
,也可以将状态组返回到其基本状态。
另请参阅 Qt Quick 状态。
该属性包含状态组定义的状态列表。
StateGroup { states: [ State { // State definition... }, State { // ... } // Other states... ] }
另请参阅 Qt Quick States。
transitions : list<Transition> |
该属性包含状态组定义的转换列表。
StateGroup { transitions: [ Transition { // ... }, Transition { // ... } // ... ] }
另请参阅 "转换"。
© 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.