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. list of images with different sources [Repeater]
Forum Updated to NodeBB v4.3 + New Features

list of images with different sources [Repeater]

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 156 Views
  • 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.
  • M Offline
    M Offline
    mIcHyAmRaNe
    wrote on last edited by
    #1

    Hello, i'm creating a small app using qml (+ pyside2) but i'm facing some small qml problems.

    i have an array of pictures urls, and i want to create a list of images that differ in sources (url that i get from the array) but i dont know how to make that possible ...

    i'm trying different approach to see what happen, but i'm getting an error saying that the assigned id is not defined (ReferenceError: pic is not defined) when the id is inside reapeter

    here is my code:

    Grid {
            columns: 1
            spacing: 2
            Rectangle { color: "red"; width: 200; height: 200;
                Column {
                    Repeater {
                        Image {
                            id: pic
                            source: ""
                        }
                    }
                }
            }
            
            Button {
                text: "Load"
                onClicked: {
                    var img = ['https://pbs.twimg.com/profile_images/875749462957670400/T0lwiBK8_400x400.jpg', 
                        'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQNWZZEtSli3K3SYZN-Mhsl0WPo_1o6qYQ5ag&usqp=CAU'];
                    
                    for (var i = 0; i < img.length; i++) {
                        pic.source = img[i]
                    }
                }
            }
        }
    

    Thank you

    1 Reply Last reply
    1
    • M Offline
      M Offline
      mIcHyAmRaNe
      wrote on last edited by
      #2

      after perseverence, I ended up finding a good approach.
      but I stay tuned if there is better: delegate-prop

      Grid {
              columns: 1
              spacing: 2
              Rectangle { color: "red"; width: 200; height: 200;
                  Column {
                      Repeater {
                          id: rep
                          Image {
                              source: modelData
                          }
                      }
                  }
              }
              
              Button {
                  text: "Load"
                  onClicked: {
                      var img = ['https://pbs.twimg.com/profile_images/875749462957670400/T0lwiBK8_400x400.jpg', 
                          'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQNWZZEtSli3K3SYZN-Mhsl0WPo_1o6qYQ5ag&usqp=CAU'];
                      rep.model = img
                  }
              }
          }
      
      
      1 Reply Last reply
      1

      • Login

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