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

Repeater's count and itemAt() not always correct

XMLWordPrintable

    • a9f1eaa6a368bf7a72b52c428728a3e3e0a76209

      Run the code below and note the initial output in the console,
      which is correct. Click the window, and note that number of items
      printed in the console is 4 rather than 7, followed by an error.

      import QtQuick 1.1
      
      Item {
          width: 640
          height: 480
      
          Column {
              anchors.centerIn: parent
      
              Repeater {
                  id: repeater
                  model: 4
                  onModelChanged: printWidths()
                  delegate: Rectangle {
                      color: "red"
                      width: (index+1)*50
                      height: 50
                  }
              }
          }
      
          Component.onCompleted: printWidths()
      
          function printWidths() {
              print("Repeater has " + repeater.count +  " items")
              for(var i = 0; i < repeater.count; i++) {
                  var c = repeater.itemAt(i);
                  print("Width of item " + i + ": " + c.width)
              }
          }
      
          MouseArea {
              anchors.fill: parent
              onClicked: repeater.model = 7
          }
      }
      

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

            bealam Bea Lam (closed Nokia identity) (Inactive)
            mathiasm Mathias Malmqvist
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes