Unsolved TreeView and scrolling
-
Hi,
I would like to implement a lazy loading in my treeview with the scrollindicator.
I'm wondering how to be notified when the scroll position in my treeview reach the bottom to load next entries ? -
@ikit said in TreeView and scrolling:
I'm wondering how to be notified when the scroll position in my treeview reach the bottom to load next entries ?
You don't need to. If you use canFetchMore() and fetchMore() functions, they automatically respond to the scroll bard being close to the bottom.
-
Thanks for your answer.
I tried to implement fetchMore() and canFetchMore, but, the canFetchMore is called only one time, just after the end of the init of my treemodel (when i call endResetModel() instead of the scrollindicator close to the bottom), and then the canFetchMore is no more called... I suppose that Qt assume that I load all remaining entries in the fetchMore...
-
See the example. It definitely does work, I've used it in 2 separate QML projects.
-
I checked my code and test again, but I still have the problem. The example use a ListView and not a TreeView. That's probably why the behavior is not the same with me.
According to the Qt documentation : the fetchMore() method shall do : "Fetches any available data for the items with the parent specified by the parent index." So if I understand well (I'm not fluent in english), it's normal that the fetchMore was called only one time. because this method is supposed to load all sub-entries for the provided item.
-
No, the implementation is entirely up to you. In my code, I used to hardcode it to fetch only 10 more items.
Perhaps it is like you describe, though. Tree view is a late addition to QtQuick, maybe it is buggy. Unfortunately I can't check now, I'm not at my PC.
Maybe try calling canFetchMore manually when your tree view reaches the bottom? Flickable should have some slots invoked after scrolling, and you can compare that against contentRect. Sorry again that I won't link to relevant portion of the documentation, I'm writing from my phone and it is a bit tricky ;-)