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

Make SignalTransition.guard compilable with qmlsc

    XMLWordPrintable

Details

    Description

      SignalTransition.guard is documented as a bool property, but is implemented under-the-hood as a QQmlScriptString

       

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

      import QtQuick
      import QtQuick.Controls.Basic
      import QtQml.StateMachine as DSM
      
      Window {
          width: 640
          height: 480
          visible: true
      
          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"
              }
          }
      }
      

       

      Compiler output

      Warning: main.qml:19:24: Cannot assign binding of type bool to QQmlScriptString [incompatible-type]
                      guard: guardButton.checked
                             ^^^^^^^^^^^^^^^^^^^
      Warning: main.qml:19:43: Could not compile binding for guard: cannot convert from bool of QQuickAbstractButton::checked with type bool to QQmlScriptString of QQmlScriptString [compiler]
      

      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:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes