이 페이지에서

SignalTransition QML Type

SignalTransition 유형은 Qt 신호를 기반으로 한 전환을 제공합니다. 더 보기...

Import Statement: import QtQml.StateMachine 6.12
Inherits:

QSignalTransition

속성

상세 설명

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

가드 조건은 평가 결과가 참일 때만 전환을 허용하고, 거짓일 때는 전환을 차단함으로써 상태 머신의 동작에 영향을 미칩니다.

이 신호 전환과 관련된 신호가 발신되면 가드 조건이 평가됩니다. 가드 조건에서는 아래 예제에서 보여준 것처럼 신호의 인수를 사용할 수 있습니다.

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

© 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.