Quantcast
Channel: Active questions tagged qtquick2 - Stack Overflow
Viewing all articles
Browse latest Browse all 107

Limit the number of items displayed in ListView

$
0
0

I have a ListViewListModel with 10 ListElements, I want the ListView to display the first ListElement from the model.

Is there a way to limit the number of ListElement items that are displayed, or select the ListElement to display from an ID in the data?

Example ListModel:

ListModel {    id: homeMenuModelData    ListElement {        name: "Sam Wise Is A Very Wise Man"        number: "555 0473"    }    ListElement {        name: "Bill Smith"        number: "555 3264"    }    ListElement {        name: "John Brown"        number: "555 8426"    }}

The ListView:

ListView {    anchors.fill: parent    interactive: false    model: HomeMenuModel    delegate: homeMenuDelegate    highlight: Rectangle { color: "lightsteelblue"; radius: 5 }    focus: true}

I'm thinking something like this would be useful to me:

model.clear();for( var i=0; i < bookList.length ; ++i ) {    model.append(bookList[i]);}

Viewing all articles
Browse latest Browse all 107

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>