SignalTransition QML Type

SignalTransition 型は Qt シグナルに基づくトランジションを提供します。詳細...

Import Statement: import QtQml.StateMachine 6.8
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
            }
        }
    }
}

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