[PyQt] Newbee: Approach to expand QTreeView completely below selected index

Knacktus knacktus at googlemail.com
Fri Oct 8 17:42:26 BST 2010


Hi everyone,

I'm writing my first app, so I'm sometimes a bit unsure if my approaches 
are recommended practice.

To expand everything below a selected index in a TreeView with custom 
QAbstractItemModel, I've done the following (I didn't find a predefined 
slot for this case, only for expanding one level or the whole tree):

1) expand the index using the slot expand(index)
2) get the number of rows  from TreeModel.rowCount()
3) loop over the rows and get the child indexes from TreeModel.index()
4) go recursively to step 1)

Is that the way to go or do I miss some other, better approach?

Thanks in advance,

Jan


More information about the PyQt mailing list