Getting Child Items from QStandardItemModel
Hi Guys,
I have a QStandardItemModel. I need to get a Children QVariantList OR QStandardItemModel itself by giving an QModelIndex() of the parent.
For ex: A tree as below,
Code:
+Parent1
+ Child10
- Child11
- GrandChild110
- GrandChild111
- GrandChild112
+Parent2
+ Child20
- Child21
- GrandChild210
- GrandChild211
- GrandChild212
+Parent3
By giving the QModelIndex() of parent item "Parent1" I need to get a QVariantList or QStandardItemModel of the children Items of the
same. Like.
Code:
+ Child10
- Child11
- GrandChild110
- GrandChild111
- GrandChild112
Please let me know how it can be done.
Thanks
Nikhil
Re: Getting Child Items from QStandardItemModel
This looks like a job for a proxy model. My knowledge level is not really good enough to rattle off an exact solution. Have a read of the QAbstractProxyModel documentation and a look at the browser demo's history handling models and this related QtLabs article.
Re: Getting Child Items from QStandardItemModel
Thanks Chris. I will look into it.
Guys, Anybody who have done like this. Please help me out.
Thanks.
Re: Getting Child Items from QStandardItemModel
Hey!
treeView->setRootIndex(...) will do the necessary. Thanks.
Re: Getting Child Items from QStandardItemModel
Hi,
I am also facing the similar issue, but I didnt get the usage of "treeView->setRootIndex(...)". Could you please explain more?