Reputation: 385
I want to output a list of users on a login page. For this I have created an userlistmodel based on QAbstractListModel and fill that with two users. So far everything works, on the qml page I get the output that 2 elements are in the listview.
I have assigned the model to the listview and set a small component as delegate.
logon.qml
Rectangle {
id: userlist
Layout.fillWidth: true
Layout.fillHeight: true
Layout.preferredHeight: 300
Layout.preferredWidth: 560
color: "white"
RowLayout
{
ListItem { text1: "Benutzeranmeldung"; text2: "[1/2]"; icon: "key" }
ListView {
model: user.model
clip: true
delegate: ListItem { text1: name; text2: ""}
}
}
}
ListItem.qml
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import Exakt.Mills.System.ColorEnums 1.0
Item {
id: item
height: 30
width: 400
property string text1
property string text2
property string icon
Rectangle {
anchors.fill: parent
Layout.fillWidth: true
Layout.fillHeight: true
color : "grey"
RowLayout {
Image {
sourceSize.height: item.height * 0.8
source: "image://iconprovider/user"
}
Label {
text: text1
}
Label {
text: text2
}
}
}
}
Unfortunately only the first (static) list entry is displayed, but the two users are not displayed. Alignment and formatting are still missing, it is first about the pure output
Upvotes: 0
Views: 41
Reputation: 26309
Neither your RowLayout
nor your ListView
have dimensions. The minimal fixes required are:
RowLayout {
anchors.fill: parent
ListView {
Layout.fillWidth: true
Layout.fillHeight: true
}
}
Upvotes: 1