How To Expand Top-level Qtreeview Items
I do not understand why this does not seem to expand the top-level root items in a QTreeView: # clear existing treeview data model = self.treeview.model().sourceModel() model.clear
Solution 1:
If you're using a proxy model, you must use the indexes it provides, rather than the ones from the source model. So either do this:
proxy = self.treeview.model()
for row inrange(proxy.rowCount()):
index = proxy.index(row, 0)
self.treeview.expand(index)
or this:
proxy = self.treeview.model()
model = proxy.sourceModel()
for row inrange(model.rowCount()):
index = model.index(row, 0)
self.treeview.expand(proxy.mapFromSource(index))
Post a Comment for "How To Expand Top-level Qtreeview Items"