Uploaded image for project: 'Qt for MCUs'
  1. Qt for MCUs
  2. QTMCU-227

Having a white space in the name property of State causes a compilation error

    XMLWordPrintable

Details

    • All
    • 604fc9fd, 55c1583b, b62f6d4e, e13b4685

    Description

      Having a white space in the name property of State causes a compilation error in Qt for MCUs while it doesn't in Qt6.

      With this code:

      import QtQuickRectangle {
          id: root
          color: "black"
          MouseArea {
              id: mouseArea
              anchors.fill: parent
          }    
          states: [
              State {
                  name: "red screen" // <-- space is there
                  when: mouseArea.pressed
                  PropertyChanges { target: root; color: "red" }
              },
              State {
                  name: "blue screen" // <-- space is there
                  when: "Hello" === "World"
                  PropertyChanges { target: root; color: "blue" }
              }
          ]
      }
       

      I got this error in the generated C++ code. (basically a lot, due to the white space. Please try this out with the attached project 01_Define_and_Transition_States.zip)

      I also attached a simple example(untitled6.aip) which builds with Qt 6.6. This works.

      // main.qml
      import QtQuick
      import contentWindow {
          id: root
          visible:true
          width: 472; height: 272
          Rectangle {
              id: rect
              anchors.fill: parent
              color: "black"        
              MouseArea {
                  id: mouseArea
                  anchors.fill: parent
                  onPressed: {
                      console.log("pressed")
                  }
              }        
              states: [
                  State {
                      name: "red screen" // <-- space
                      when: mouseArea.pressed
                      PropertyChanges { target: rect; color: "red" }
                  },
                  State {
                      name: "blue screen" // < -- space
                      when: mouseArea.released
                      PropertyChanges { target: rect; color: "blue" }
                  }
              ]
          }
      }
       

      Attachments

        Issue Links

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

          Activity

            People

              k0rahman Karim Abdelrahman
              mikio_hirai Mikio Hirai
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes