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

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

      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" }
                  }
              ]
          }
      }
       

        1. image-2023-10-18-16-00-37-189.png
          173 kB
          Mikio Hirai
        2. 01_Define_and_Transition_States.zip
          1.30 MB
          Mikio Hirai
        3. untitled6.zip
          14 kB
          Mikio Hirai
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

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

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes