I have a listview object that reads data from a web api via a javascript function that appends the data to the listmodel. I've attached the listview and listmodel below.
I want to implement a type of infinite scroll when the user gets close or reaches the last element of the listview.
I can't figure out how to detect the scroll event and grab the relative scroll position.
Thanks for any help.
ListModel {
id: subModel
function getSub(idx){
return (idx >=0 && idx < count) ? get(idx).display_name: "";
}
}
ListView {
clip: true
width: parent.width
height: parent.height - searchButton.height
model: subModel
on
delegate: ListingDelegate{
text: title;
subText: subTitle;
icon: Qt.resolvedUrl(thumbnail)
__iconWidth: units.gu(5)
__iconHeight: units.gu(5)
}
}
}
In QML every property has corresponding change signal. In your case you should listen atYEnd property of ListView:
ListView {
id: messageList
// Stuff
onAtYEndChanged: {
if (messageList.atYEnd) {
// Loading tail messages...
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With