How to set the position in QML List view
Solved
QML and Qt Quick
-
Hi Team,
I have a QML list view with several list elements.
I want to display the list view from a specific position i.e. based on contentY value.
How can I implement this ?Please find the sample code and picture below
ListModel { id: contactModel ListElement { name: "Bill Smith" number: "555 3264" } ListElement { name: "John Brown" number: "555 8426" } ListElement { name: "Sam Wise" number: "555 0473" } ListElement { name: "Shyam" number: "555 0473" } ListElement { name: "Birbal" number: "555 0473" } ListElement { name: "Rudra" number: "555 0473" } ListElement { name: "Samyukta" number: "555 0473" } ListElement { name: "Akh" number: "555 0473" } ListElement { name: "Chris" number: "555 0473" } } ListView { id: listView anchors.fill: parent model: contactModel delegate: Text { font.pixelSize: 14 text: name + ": " + number } }
-
@Praveen-Illa said in How to set the position in QML List view:
I want to display the list view from a specific position i.e. based on contentY value.
How can I implement this ?You have answered yourself here: use
contentY
property :-) For example:ListView { // ... Component.onCompleted: contentY = 50 }
There are also other methods to better position the views, see the docs: https://doc.qt.io/qt-5/qml-qtquick-listview.html#positionViewAtIndex-method