[SOLVED]: ListView spacing
-
Hi,
it seems the "spacing" property of the ListView component actually set the spacing between each item. Instead I want to set the distance from the center of them - no matter of their width.Is there a simple way to achieve this?
-
Make the delegate have 0 width, and create "real" item as its' child, but this time give it the width you desire.
-
So I tried the following:
@
Component {
id: modelDelegate
Item {
width: 0
anchors.verticalCenter: parent.verticalCenter
Text {
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
text: value
width: 100
}
}
}
@But changing the width of the child (the Text component) leads to change the position of the items.
Perhaps I miser-understood your hint? -
I think you understood well. Maybe my hint was not so good ;-) Try bumping the width to 1 - QMl engine might misinterpret width 0 as "invisible".
@
delegate: Item {
height: 1
width: 1Text {
anchors.centerIn: parent
text: value
width: 100
}
}
@ -
I think I found the problem. It works until the items overlap each other. But I can live with this "feature"!
-
Yes, that will not take item collision into account, as we are fooling the ListView into thinking that the item is very small, when in reality it is not.