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

Changes assigning into array property

XMLWordPrintable

    • 07d2a80d0 (dev), a521216b7 (6.5), 942a53490 (6.4)

      While working with MultiEffect example I came up with behavior change in Qt Quick engine. Simplified QML code here:

          property var myItem: []
      
          Component.onCompleted: {
      
              // This makes it work with Qt 6.4.0 & 6.4.1
              //console.debug("hello");
      
              myItem[0] = 10;
      
              // This makes it work also with Qt dev
              //console.debug("myItem" + myItem[0]);
      
              // This works
              //myItem.push(10);
          }
      
          Timer {
              interval: 1000
              running: true
              onTriggered: {
                  console.debug(myItem[0]);
              }
          }
      

      With Qt 6.3 that prints "10" OK. With 6.4 it prints "undefined", unless you enable that first line. With dev, "undefined" unless you enable that second line.

      Array push works, but isn't assigning with [] also OK in JavaScript?

      I can workaround this but just interested to know if it is a bug or bad example / expected behavior...?

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

            ulherman Ulf Hermann
            kagro Kaj Grönholm
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: