SignalTransition QML Type
SignalTransition 类型提供基于 Qt 信号的转换。更多
Import Statement: | import QtQml.StateMachine 6.9 |
Inherits: |
属性
详细说明
SignalTransition 是Qt State Machine QML API 的一部分。
使用示例
import QtQuick import QtQml.StateMachine as DSM Rectangle { DSM.StateMachine { id: stateMachine initialState: state running: true DSM.State { id: state DSM.SignalTransition { targetState: finalState signal: button.clicked guard: guardButton.checked } } DSM.FinalState { id: finalState } onFinished: Qt.quit() } Row { spacing: 2 Button { id: button text: "Finish state" } Button { id: guardButton checkable: true text: checked ? "Press to block the SignalTransition" : "Press to unblock the SignalTransition" } } }
另请参阅 StateMachine,FinalState, 和TimeoutTransition 。
属性文档
guard : bool |
保护条件(Guard Condition)影响状态机的行为,只有当它们评估为 true 时才启用转换,当它们评估为 false 时才禁用转换。
当与此信号转换相关的信号发出时,会对保护条件进行评估。在保护条件中,可以使用信号的参数,如下例所示。
import QtQuick import QtQml.StateMachine as DSM Rectangle { Button { anchors.fill: parent id: button DSM.StateMachine { DSM.State { DSM.SignalTransition { targetState: finalState signal: button.mysignal // the guard condition uses the mystr string argument from mysignal guard: mystr == "test" } } DSM.FinalState { id: finalState } } // define the signal the SignalTransition is connected with signal mysignal(mystr: string) // on clicking the button emit the signal with a single string argument onClicked: button.mysignal("test") } }
另请参见 signal 。
signal : signal |
与此信号转换相关的信号。
import QtQuick import QtQml.StateMachine as DSM Rectangle { Button { anchors.fill: parent id: button DSM.StateMachine { DSM.State { DSM.SignalTransition { targetState: finalState signal: button.clicked } } DSM.FinalState { id: finalState } } } }
© 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.