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

The size of an array declared as a QML object property can't be altered directly

    XMLWordPrintable

Details

    Description

      If you try the following QML example, clicking the red rectangle doesn't increase the size of an array while the green one does. Both should.

      import Qt 4.6
      
      Rectangle {
          width: 640
          height: 480
          id: rect
          property var array: new Array
      
          Rectangle {
              height: 50
              width: 50
              color: "red"
              MouseRegion {
                  anchors.fill: parent
                  onClicked: {
                      print("before append, size is" + rect.array.length);
                      rect.array[rect.length] = null;
                      print("after append, size is" + rect.array.length); //should be 1 more
                  }
              }
          }
          Rectangle {
              x: 60
              height: 50
              width: 50
              color: "green"
              MouseRegion {
                  anchors.fill: parent
                  onClicked: {
                      print("before append, size is" + rect.array.length);
                      var arr = rect.array;
                      arr[arr.length] = null;
                      rect.array = arr;
                      print("after append, size is" + rect.array.length); //should be 1 more
                  }
              }
          }
      }
      

      Attachments

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

        Activity

          People

            aakenned Aaron Kennedy
            vfm Thierry Bastian (closed Nokia identity) (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes