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

properties do not get restored to correct value after state change

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • Qt for MCUs 1.5
    • QML, QML Engine, QUL Team
    • None
    • All
    • 8
    • QUL Sprint 1.6/2022

    Description

      If a custom widget changes its properties based on a state change, the original property value gets overwritten with default property value and not with the instantiated value

      root example qml:

      Rectangle {
          id: test
          width: 1280
          height: 720
          color: "black"
      
          Timer{
              interval: 1500
              running: true
              repeat: true
              onTriggered: rect.state = (rect.state === "Test1"? "Test2" : "Test1")
          }
      
          Rect {
              id: rect
              x: 200
              y: 100
          }
      }
      

      custom item QML:

      Rectangle{
          id: rect
          width: 100
          height: 100
          color: "red"
          
          states: [
              State {
                  name: "Test1"
              },
              State {
                  name: "Test2"
                  
                  PropertyChanges{
                      target: rect
                      x: (500 - width) / 2
                      y: (500 - height) / 2
                  }
                  
              }
          ]
      }
      

      It looks like this is valid for all properties, I tested it for x, y, width, height, color.

      Looking into the sourc code this is obvious, as the retun value for all states is hardcoded the default value and not the actual value from intantiation.

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            _joerg_ Jörg Hedrich
            Daniel Drozdz Daniel Drozdz
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes