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

Full array support for QML list properties (and variant properties that contain lists)

    XMLWordPrintable

Details

    Description

      Please consider the following example. I can only work with the property, after reassigning it to a local variable aa:

      import Qt 4.7
      
      Rectangle {
          id: rect
          width: 640
          height: 480
      
          property variant a: []
      
          Component.onCompleted: {
              console.log("a===rect.a:", a===rect.a);
              console.log("isArray:", Array.isArray(a));
              for(var i=0; i< 4; i++) {
                  a.push( i );
                  console.log(i, "a > ", JSON.stringify(a), a.length);
              }
      
              var aa = rect.a;       // reassigning fixed the problem
              for(var i=0; i< 4; i++) {
                  aa.push( i );
                  console.log(i, "aa > ", JSON.stringify(aa), aa.length);
              }
      
          }
      }
      /*
      Outputs the following:
      
      a===rect.a: false
      isArray: true
      0 a >  [] 0
      1 a >  [] 0
      2 a >  [] 0
      3 a >  [] 0
      0 aa >  [0] 1
      1 aa >  [0,1] 2
      2 aa >  [0,1,2] 3
      3 aa >  [0,1,2,3] 4
      */
      

      Attachments

        1. testLoop.qml
          0.7 kB
        2. SpliceBug.qml
          0.5 kB

        Issue Links

          Activity

            People

              brasser Michael Brasser (closed Nokia identity) (Inactive)
              pixtur Thomas Mann
              Votes:
              24 Vote for this issue
              Watchers:
              14 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: