PDA

View Full Version : QTreeView and RootIndex



Qiieha
6th March 2013, 16:48
Hi guys,
i have a problem. I use a QTreeView and with a subclass of QAbstractItemModel.
It works.
A
..B
..C
....D
For filter reasons I change the root index via setRootIndex.


setRootIndex(B);


It works, but after setting the root index, the rootIndex is not shown. (rootIsDecorated is true.)
C
....D

Furthermore I'm not able to unset the filter, because my A node never gets back.


setRootIndex(A); // A is model.index(0,0);


What can I do?
thanks

wysota
7th March 2013, 14:23
Root index is never shown. The view always shows children of the root index.

Qiieha
8th March 2013, 08:31
Thank you wysota!
If I don't set the rootIndex initially, the root index is shown.

greets

wysota
8th March 2013, 10:41
Because it is set to an invalid index (QModelIndex()) which happens to point to the top of the model.