Reputation: 3206
Given this QML:
ApplicationWindow {
id: window
width: 640
height: 480
visible: true
color: "black"
ListView {
id: myView
anchors.fill: parent
model: [12, 12, 12, 12, 12, 12, 12, 12]
delegate: ItemDelegate {
width: parent.width
contentItem: Rectangle {
color: "blue"
}
}
spacing: 0
}
}
The listview, or the individual rows will render with a spacing around them:
How can I remove this spacing? What I need is no border around the listview relative to the ApplicationWindow, and a 1px spacing between listview rows.
Upvotes: 0
Views: 583
Reputation: 463
Seems like you forget to mention the height of the delegate item
ApplicationWindow {
id: window
width: 640
height: 480
visible: true
color: "black"
ListView {
id: myView
anchors.fill: parent
model: [12, 12, 12, 12, 12, 12, 12, 12]
delegate: ItemDelegate {
width: parent.width
height: 20
contentItem: Rectangle {
anchors.fill: parent
color: "blue"
}
}
spacing: 1
}
}
Upvotes: 1
Reputation: 2711
I am not sure what is the point of your ItemDelegate
, but from your description I think you need to do something like this:
ListView {
id: myView
anchors.fill: parent
spacing: 1
model: [12, 12, 12, 12, 12, 12, 12, 12]
delegate: Rectangle {
color: "blue"
width: ListView.view.width
height: modelData
}
}
Upvotes: 1