6

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)
            }
        }
    }
4

1 回答 1

7

在 QML 中,每个属性都有相应的变化信号。在您的情况下,您应该收听 ListView 的 atYEnd 属性:

ListView {
  id: messageList
  // Stuff
  onAtYEndChanged: {
    if (messageList.atYEnd) {
      // Loading tail messages...
    }
  }
}
于 2013-02-26T19:11:47.003 回答