SignalTransition QML Type
O tipo SignalTransition fornece uma transição baseada em um sinal do Qt. Mais...
| Import Statement: | import QtQml.StateMachine 6.12 |
| Inherits: |
Propriedades
Descrição detalhada
SignalTransition faz parte da API QML dQt State Machine .
Exemplo de uso
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"
}
}
}Veja também StateMachine, FinalState e TimeoutTransition.
Documentação da propriedade
guard : bool
As condições de guarda afetam o comportamento de uma máquina de estados, permitindo transições apenas quando seu resultado é verdadeiro e impedindo-as quando o resultado é falso.
Quando o sinal associado a essa transição de sinal é emitido, a condição de guarda é avaliada. Na condição de guarda, os argumentos do sinal podem ser utilizados conforme demonstrado no exemplo abaixo.
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")
}
}Veja também signal.
signal : signal
O sinal associado a essa transição de sinal.
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
}
}
}
}© 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.