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
↧