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

Setting a VisualItemModel for a Repeater appends to the Repeater, rather than replacing.

    XMLWordPrintable

Details

    • 17cc89e918a969d85d2b46631ee8743288c7586d

    Description

      Setting a VisualItemModel for a Repeater has the effect of appending the items to the Repeater.

      Take a look at the example code below. Click on one of the grey buttons to set the Repeater content to 3 Rectangles. Click the other grey button to set 3 different Rectangles. The Repeater ends up with 6 rectangles, even though Repeater.count says 3...

      import Qt 4.7

      Rectangle {
      width: 200
      height: 800

      Column {
      y: 200
      Repeater

      { id: fred }

      }

      VisualItemModel {
      id: model0
      Rectangle

      { width: 100; height: 20; color: "red" }

      Rectangle

      { width: 100; height: 20; color: "green" }

      Rectangle

      { width: 100; height: 20; color: "blue" }

      }
      VisualItemModel {
      id: model1
      Rectangle

      { width: 100; height: 20; color: "yellow" }

      Rectangle

      { width: 100; height: 20; color: "orange" }

      Rectangle

      { width: 100; height: 20; color: "pink" }

      }

      Rectangle {
      width: 100
      height: 30
      color: "grey"
      Text

      { text: "Set to model0" }

      MouseArea {
      anchors.fill: parent
      onClicked:

      { fred.model = model0; }

      }
      }

      Rectangle {
      y: 40
      width: 100
      height: 30
      color: "grey"
      Text

      { text: "Set to model1" }

      MouseArea {
      anchors.fill: parent
      onClicked:

      { fred.model = model1; }

      }
      }

      Text

      { y: 80; text: "Number of items = " + fred.count }

      }

      Attachments

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

        Activity

          People

            martjone Martin Jones (closed Nokia identity) (Inactive)
            clivewhitear Clive Whitear
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes