Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

First steps with ListView

$
0
0
Hi, I’m trying to build a little user list using ListView. What I’d like to have is a list of rectangles, each containing a image (avatar icon) on the left and a text (username) on the right. This is what I tried so far (using always the same image, but that doesn’t matter right now): import QtQuick 2.4   Item {   id: itemPageStatistics     ListModel   {     id: model     ListElement     {       icon: "qrc:/img/avatar.png"       text: "User A"     }       ListElement     {       icon: "qrc:/img/avatar.png"       text: "User B"     }   }     ListView   {     anchors.top: parent.top     anchors.left: parent.left     anchors.leftMargin: 10     anchors.horizontalCenter: parent.horizontalCenter     height: 300       model: model     Component     {       id: compDelegate         Item       {         Image         {           source: icon         }           Text         {           text: text         }       }     }     delegate: compDelegate   } } The problem is, that only one avatar image and nothing else (no second avatar image and zero text) is shown… My first intention was that I forgot to give a height to the parent item, but that also doesn’t help… Any suggestions? :-P

Viewing all articles
Browse latest Browse all 4972

Trending Articles