QML listview how to set space between header and first item
-
I use the header property in the listview element.
How can I get a space between the header and the first list entry?
The space between the list entries works, but not the space between the header and the first line.This is my listview code
ListView { Layout.fillWidth: true; Layout.fillHeight: true model: user.model currentIndex: 1 onCurrentIndexChanged: { console.log("currentIndex changed") } header: UserItemDelegate { p_index: -1; p_name: "Benutzeranmeldung"; p_icon: "password"; p_isHeader: true } delegate: UserItemDelegate { p_index: index; p_name: name; p_icon: icon; p_isHeader: false } spacing: 20 }
UserItemDelegate looks like this but that may not be important to my question
Item { id: root height: configuration.getSize(Sizes.ListItemHeight) width: parent.width property int p_index property string p_name property string p_icon property bool p_isHeader property bool p_isSelected: root.ListView.view.currentIndex == p_index property string p_color: configuration.getColor(p_isHeader ? Colors.ListItemDisabled : (p_isSelected ? Colors.ListItemSelected : Colors.ListItemDefault)) Rectangle { anchors.fill: parent; Layout.fillWidth: true; Layout.fillHeight: true; color: p_color RowLayout { anchors.verticalCenter: parent.verticalCenter; Image { Layout.leftMargin: 10; sourceSize.height: root.height * 0.6; source: "image://iconprovider/" + p_icon } Label { Layout.leftMargin: 10; text: p_name } } MouseArea{ enabled: !p_isHeader; anchors.fill: parent; onClicked: { root.ListView.view.currentIndex = p_index; } } } }