I would like to have a ListView
that fit to the width of its largest item.
I also want the items to be right-aligned in the ListView
.
So, as a naive approach, I've done that:
Window { width: 640 height: 480 visible: true title: qsTr("Hello World") id: window ListView { id: view anchors.left: window.left height: contentHeight spacing: 5 // making the list the width of its content width: contentItem.childrenRect.width model: ["A", "bb", "CCcc", "DDddDD"] delegate: Text { text: modelData font.pointSize: 24 // aligning the item to the right anchors.right: parent.right } }}
Visually, it is working. However I am getting this warning:
QML ListView: Binding loop detected for property "width"
So, this approach doesn't seem to be the correct way of achieving what I want.
I've tried other things too, like setting the implicitWidth
(with the same result), or setting contentWidth
instead or horizontalAlignment: Text.AlignRight
in the Text
but with a wrong visual result.
So, I'm wondering, is there a proper way to align items to the right in a ListView
, or do I have to live with that warning?