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

QML's list ought to support JavaScript's for(var i in list) syntax

    XMLWordPrintable

Details

    • 4e931c4a436ea3dcf6e1921488771aa1e79eda13

    Description

      Run the code below. Note the output to the console, which is as expected.

      Comment out the first for-loop, and comment in the other one. Run again and
      note that the output to the console is now "child: 4" rather than the expected.

      import QtQuick 2.0
      Rectangle {
          width: 400; height: 600
          Column {
              anchors.centerIn: parent
              spacing: 3
              Repeater {
                  model: 3
                  delegate: Rectangle {
                      width: 50; height: 50; color: "blue"
                  }
              }
      
              Component.onCompleted: {
                  for(var i = 0; i < children.length; i++) {       // works
                      print("child: " + children[i].toString());
                  }
      
      //            for(var i in children) {                       // doesn't work
      //                print("child: " + children[i].toString());
      //            }
              }
          }
      }
      

      Attachments

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

        Activity

          People

            brasser Michael Brasser (closed Nokia identity) (Inactive)
            mathiasm Mathias Malmqvist
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes