Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-112408 Make SignalTransition compilable with qmlsc
  3. QTBUG-112411

Update SignalTransition API to avoid relying on injected signal parameters

    XMLWordPrintable

Details

    Description

      Parameter injection has been deprecated for signal handlers (https://doc.qt.io/qt-6/qtqml-syntax-signals.html#signal-parameters ). The same needs to be done for SignalTransition.guard, somehow

       

      Code (adapted from https://doc.qt.io/qt-6/qml-qtqml-statemachine-signaltransition.html#guard-prop )

      import QtQuick
      import QtQuick.Controls.Basic
      import QtQml.StateMachine as DSM
      
      Window {
          width: 640
          height: 480
          visible: true
      
          Button {
              id: button
              text: "Quit"
              // 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")
          }
          DSM.StateMachine {
              id: stateMachine
              initialState: state
              running: true
              DSM.State {
                  id: state
                  DSM.SignalTransition {
                      targetState: finalState
                      signal: button.mysignal
                      guard: mystr === "test"
                  }
              }
              DSM.FinalState {
                  id: finalState
              }
              onFinished: Qt.quit()
          }
      }
      

       

      Compiler output

      Warning: main.qml:27:24: Could not compile binding for guard: Cannot access value for name mystr [compiler]
                      guard: mystr === "test"
                             ^^^^^
      

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              qtqmlteam Qt Qml Team User
              skoh-qt Sze Howe Koh
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes