0

I'm using a QListView which wraps a very simple list model. I would like to try implementing something similar to the "infinite scroll" seen in some web pages.

Currently the model is updated by a method which adds at most 100 items (they're taken from an external web API which takes at most 100 items per call). My goal: when the user moves to the last element of the list view (in my case, by scrolling down) I would like to start a call to get up to 100 more items, and so on.

To simplify in this example:

  1. Populate the list with 100 items
  2. View scrolled down (by user) to the bottom
  3. Other 100 items fetched.

Is there anything in QListView that tells me when I'm at the end of the visible view?

4

1 回答 1

3

QListView是 的子类QAbstractScrollArea,因此找出垂直滚动条的位置是否处于其极端之一的一种方法是:

  1. 通过调用获取QScrollBar使用的对象。QListViewverticalScrollBar()
  2. sliderMoved(int value)将滚动条的信号连接到您选择的插槽。
  3. 在槽中,获取滚动条的最小/最大值并将它们与信号中给出的值进行比较。
于 2013-07-21T20:05:39.697 回答