I'm using PyQt 4.4.
It's best shown using some pictures. All nodes should have leafs from 0 to 99. They are being incrementally loaded using canFetchMore()
and fetchMore()
. But for some reason unknown for me this works only for the root node. (Picture 1)
If I collapse and expand a node it loads additional 10 values. (Picture 2 & 3)
It's also strange, that it loads 10 values, as the code loads only 5 per call to fetchMore()
, meaning this gets called 2 times before the code stops to load more data.
I've written a small example to demonstrate the problem, just run it with python test.py
.
http://snipt.org/lLh
Does anyone know what causes this error?
I took a look at the Qt source (v4.5, though I don't expect much difference between v4.4 and v4.5) for QAbstractItemView and QTreeView, and I don't think they support incremental lazy loading of child nodes.
QAbstractItemView has no notion of trees, so it only calls fetchMore()
on the top most index. It calls fetchMore()
when:
QTreeView additionally calls fetchMore()
when:
fetchMore()
with a non-root index)expandAll()
and collapseAll()
I think the best solution would be to subclass QTreeView to make it call fetchMore()
in the appropriate places and with the appropriate indices.