Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-108088

qmlsc cannot find properties of classes from qt_add_statecharts() that are registered with QML_FOREIGN

    XMLWordPrintable

Details

    Description

      QTBUG-107209 was closed after updating the documentation to show that the C++ class generated by qt_add_statecharts() can be registered in QML using QML_FOREIGN:

      struct MyMachineRegistration
      {
          Q_GADGET
          QML_FOREIGN(MyStateMachine}
          QML_NAMED_ELEMENT(MyStateMachine}
      };
      

      The resulting application does work correctly, but qmlsc produces a number of warnings/errors during compilation.

      Attached is an attempt to convert the static Qt SCXML Traffic Light Example (https://doc.qt.io/qt-6/qtscxml-trafficlight-widgets-static-example.html ). Here, the state machine was put in a standalone library to avoid the possibility that files are compiled in the wrong order, but it produces the following warnings/errors anyway:

      [39/53 6.7/sec] Generating .rcc/qmlcache/trafficlight-qml-static_Lights.ui_qml.cpp
      Warning: Lights.ui.qml:85:39: Property "green" not found on type "TrafficLightStateMachine"
                  when: lights.stateMachine.green
                                            ^^^^^
      Error: Lights.ui.qml:85:39: Could not compile binding for when: Cannot load property green from TrafficLightStateMachine of (component in D:/dev/build-trafficlight-qml-static-Desktop_Qt_6_4_0_MSVC2019_64bit-Debug/Lights.ui.qml)::stateMachine with type TrafficLightStateMachine.
                  when: lights.stateMachine.green
                                            ^^^^^
      Warning: Lights.ui.qml:76:39: Property "yellow" not found on type "TrafficLightStateMachine"
                  when: lights.stateMachine.yellow || lights.stateMachine.blinking
                                            ^^^^^^
      Error: Lights.ui.qml:76:39: Could not compile binding for when: Cannot load property yellow from TrafficLightStateMachine of (component in D:/dev/build-trafficlight-qml-static-Desktop_Qt_6_4_0_MSVC2019_64bit-Debug/Lights.ui.qml)::stateMachine with type TrafficLightStateMachine.
                  when: lights.stateMachine.yellow || lights.stateMachine.blinking
                                            ^^^^^^
      Warning: Lights.ui.qml:62:39: Property "redGoingGreen" not found on type "TrafficLightStateMachine"
                  when: lights.stateMachine.redGoingGreen
                                            ^^^^^^^^^^^^^
      Error: Lights.ui.qml:62:39: Could not compile binding for when: Cannot load property redGoingGreen from TrafficLightStateMachine of (component in D:/dev/build-trafficlight-qml-static-Desktop_Qt_6_4_0_MSVC2019_64bit-Debug/Lights.ui.qml)::stateMachine with type TrafficLightStateMachine.
                  when: lights.stateMachine.redGoingGreen
                                            ^^^^^^^^^^^^^
      Warning: Lights.ui.qml:53:39: Property "red" not found on type "TrafficLightStateMachine"
                  when: lights.stateMachine.red
                                            ^^^
      Error: Lights.ui.qml:53:39: Could not compile binding for when: Cannot load property red from TrafficLightStateMachine of (component in D:/dev/build-trafficlight-qml-static-Desktop_Qt_6_4_0_MSVC2019_64bit-Debug/Lights.ui.qml)::stateMachine with type TrafficLightStateMachine.
                  when: lights.stateMachine.red
                                            ^^^
      [40/53 6.9/sec] Generating .rcc/qmlcache/trafficlight-qml-static_trafficlight-qml-static_qml.cpp
      Warning: trafficlight-qml-static.qml:8:9: Binding assigned to "running", but no property "running" exists in the current element.
              running: true
              ^^^^^^^
      [41/53 7.0/sec] Generating .rcc/qmlcache/trafficlight-qml-static_Button_qml.cpp
      [42/53 7.2/sec] Generating .rcc/qmlcache/trafficlight-qml-static_TrafficLight_qml.cpp
      Warning: TrafficLight.qml:23:37: Property "working" not found on type "TrafficLightStateMachine"
              button.source: stateMachine.working ? "pause.png" : "play.png"
                                          ^^^^^^^
      Error: TrafficLight.qml:23:37: Could not compile binding for source: Cannot load property working from TrafficLightStateMachine of (component in D:/dev/build-trafficlight-qml-static-Desktop_Qt_6_4_0_MSVC2019_64bit-Debug/TrafficLight.qml)::stateMachine with type TrafficLightStateMachine.
              button.source: stateMachine.working ? "pause.png" : "play.png"
                                          ^^^^^^^
      Warning: TrafficLight.qml:25:65: Property "working" not found on type "TrafficLightStateMachine"
              button.onClicked: stateMachine.submitEvent(stateMachine.working ? "smash" : "repair");
                                                                      ^^^^^^^
      Error: TrafficLight.qml:25:65: Could not compile binding for onClicked: Cannot load property working from TrafficLightStateMachine of (component in D:/dev/build-trafficlight-qml-static-Desktop_Qt_6_4_0_MSVC2019_64bit-Debug/TrafficLight.qml)::stateMachine with type TrafficLightStateMachine.
              button.onClicked: stateMachine.submitEvent(stateMachine.working ? "smash" : "repair");
                                                                      ^^^^^^^
      

      Attachments

        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:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes