Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Repeater bug?
Forum Updated to NodeBB v4.3 + New Features

Repeater bug?

Scheduled Pinned Locked Moved QML and Qt Quick
6 Posts 2 Posters 1.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    billouparis
    wrote on last edited by
    #1

    Hello I have the following basic code:
    @import QtQuick 2.0
    import QtGraphicalEffects 1.0

    Item {
    id: idRoot
    width:800
    height:480

    property real nbrOfOccurences: 10
    
    Item {
        id: idItem1
        Repeater {
            id: idImagesRepeater
            model: nbrOfOccurences
            Image {
                id: idImage
                source: "someimage.png"
                x: Math.ceil(Math.random() * 650) 
                y: Math.ceil(Math.random() * 350) 
                visible: true
            }
    
        }
    
        Repeater {
            model: nbrOfOccurences
            ColorOverlay {
                source: idItem1.children[index]
                anchors.fill: idItem1.children[index]
                color: Qt.rgba(Math.random(),Math.random(),Math.random())
                visible: true
               
            }
    
        }
        visible: true
    
    }
    

    }
    @

    -> i know that source image shall be set to false, I set them to true intentionally.
    -> running this code, I see 9 images on which a ColorOverlay is applied, and the first image does not have the ColorOverlay effect applied. Anyone can spot my error, or is it a repeater error?

    1 Reply Last reply
    0
    • B Offline
      B Offline
      billouparis
      wrote on last edited by
      #2

      The following code seems to be OK, But I still want to understand what is wrong with the original proposition in the first post?
      And yes, I know that source image shall be set to false, I set them to true intentionally.

      @ import QtQuick 2.0
      import QtGraphicalEffects 1.0

      Item {
          id: idRoot
          width:800
          height:480
       
          property real nbrOfOccurences: 10
       
      
              Repeater {
                  id: idImagesRepeater
                  model: nbrOfOccurences
                          Item {
                                      id: idItem1
      
                                        Image {
                                              id: idImage
                                              source: "someimage.png"
                                              x: Math.ceil(Math.random() * 650)
                                              y: Math.ceil(Math.random() * 350)
                                              visible: true
                                          }
                                      
                                          ColorOverlay {
                                              source: idImage
                                              anchors.fill: idImage
                                              color: Qt.rgba(Math.random(),Math.random(),Math.random())
                                              visible: true
                                          }
                          visible: true
       
                        }
              }
       
      }
      

      @

      1 Reply Last reply
      0
      • p3c0P Offline
        p3c0P Offline
        p3c0
        Moderators
        wrote on last edited by
        #3

        Hi,

        I guess that would be because the idItem1's first child would be a Repeater. Your second approach is actually the right way to do it.

        157

        1 Reply Last reply
        0
        • B Offline
          B Offline
          billouparis
          wrote on last edited by
          #4

          Hello,
          actually I printed out the children and the images are the first children indeed, the repeater is coming after the images in the children list.
          The first proposal works fine for the 9 following images, it only fails for the first one. I still would like to understand why? Is there a Qt bug or not?

          Bill

          1 Reply Last reply
          0
          • p3c0P Offline
            p3c0P Offline
            p3c0
            Moderators
            wrote on last edited by
            #5

            Try printing it in ColorOverlay since at that point only the First Repeaters Items are popluated.
            @
            ColorOverlay {
            Component.onCompleted: console.log(idItem1.children[index])
            }
            @

            157

            1 Reply Last reply
            0
            • B Offline
              B Offline
              billouparis
              wrote on last edited by
              #6

              I made additional tests, and the weird thing is the following:

              • if I spot the children changes, the result is not the same as when the component has completed. Why?
                @import QtQuick 2.0
                import QtGraphicalEffects 1.0

              Item {
              id: idRoot
              width:800
              height:480

              property real nbrOfOccurences: 2
              
              Item {
                  id: idItem1
                  Repeater {
                      id: idImagesRepeater
                      model: nbrOfOccurences
                      Item {
                          id: idImage
                          width: 100
                          height: width
                          x: width*index
                      }
                  }
              
                  Repeater {
                      model: nbrOfOccurences
                      ColorOverlay {
                          source: idItem1.children[index]
                          onSourceChanged: {
                              print ("source for index "+index+" is "+source)
                          }
                      }
                  }
                  onChildrenChanged:  {
                      print ("children Changed ")
                      var i=0
                      for (;i< 10;i++)  {
                          print("idItem1.children[ "+i+"] "+idItem1.children[i] )
                      }
                  }
              }
              
              Component.onCompleted: {
                  print ("Component on Completed ")
                  var i=0
                  for (;i< 10;i++)  {
                      print("idItem1.children[ "+i+"] "+idItem1.children[i] )
                  }
              }
              

              }

              @

              children Changed
              idItem1.children[ 0] QQuickRepeater(0x632410)
              idItem1.children[ 1] QQuickRepeater(0x631930)
              idItem1.children[ 2] ColorOverlay_QMLTYPE_1(0x631e70)
              idItem1.children[ 3] undefined
              idItem1.children[ 4] undefined
              idItem1.children[ 5] undefined
              idItem1.children[ 6] undefined
              idItem1.children[ 7] undefined
              idItem1.children[ 8] undefined
              idItem1.children[ 9] undefined
              source for index 0 is QQuickRepeater(0x632410)
              children Changed
              idItem1.children[ 0] QQuickRepeater(0x632410)
              idItem1.children[ 1] ColorOverlay_QMLTYPE_1(0x631e70)
              idItem1.children[ 2] QQuickRepeater(0x631930)
              idItem1.children[ 3] ColorOverlay_QMLTYPE_1(0x6acbf0)
              idItem1.children[ 4] undefined
              idItem1.children[ 5] undefined
              idItem1.children[ 6] undefined
              idItem1.children[ 7] undefined
              idItem1.children[ 8] undefined
              idItem1.children[ 9] undefined
              source for index 1 is ColorOverlay_QMLTYPE_1(0x631e70)
              children Changed
              idItem1.children[ 0] QQuickRepeater(0x632410)
              idItem1.children[ 1] ColorOverlay_QMLTYPE_1(0x631e70)
              idItem1.children[ 2] ColorOverlay_QMLTYPE_1(0x6acbf0)
              idItem1.children[ 3] QQuickRepeater(0x631930)
              idItem1.children[ 4] QQuickItem(0x6ac0b0)
              idItem1.children[ 5] undefined
              idItem1.children[ 6] undefined
              idItem1.children[ 7] undefined
              idItem1.children[ 8] undefined
              idItem1.children[ 9] undefined
              _children Changed _
              idItem1.children[ 0] QQuickItem(0x6ac0b0)
              idItem1.children[ 1] QQuickRepeater(0x632410)
              idItem1.children[ 2] ColorOverlay_QMLTYPE_1(0x631e70)
              idItem1.children[ 3] ColorOverlay_QMLTYPE_1(0x6acbf0)
              idItem1.children[ 4] QQuickRepeater(0x631930)
              idItem1.children[ 5] QQuickItem(0x6ace90)
              idItem1.children[ 6] undefined
              idItem1.children[ 7] undefined
              idItem1.children[ 8] undefined
              idItem1.children[ 9] undefined

              source for index 0 is QQuickItem(0x6ac0b0)
              source for index 1 is QQuickRepeater(0x632410)
              Component on Completed
              idItem1.children[ 0] QQuickItem(0x6ac0b0)
              idItem1.children[ 1] QQuickItem(0x6ace90)
              idItem1.children[ 2] QQuickRepeater(0x632410)
              idItem1.children[ 3] ColorOverlay_QMLTYPE_1(0x631e70)
              idItem1.children[ 4] ColorOverlay_QMLTYPE_1(0x6acbf0)
              idItem1.children[ 5] QQuickRepeater(0x631930)
              idItem1.children[ 6] undefined
              idItem1.children[ 7] undefined
              idItem1.children[ 8] undefined
              idItem1.children[ 9] undefined

              How come the last children change event, does not reflect the same order of children as when the component is completed? Shouldn't it be necessary to have another children change event inbetween that would reflect the same order as when the component has completed?

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved