[Solved]Find a Child in a QTreeView
-
Hi volker,
Well i have tried with findItems (and match), but the standarditemmodel only has the root items not the childs....I had to iterate just as Gerolf says...
-
[quote author="gronerth" date="1301602957"]is QHash quicker?[/quote]
Possibly but it does not store the items in an ordered manner which is sometimes useful to have if you need to iterate over them in some specific order. Depends upon the exact use case you wish to cater for. -
[quote author="gronerth" date="1301605423"]Hi volker,
Well i have tried with findItems (and match), but the standarditemmodel only has the root items not the childs....I had to iterate just as Gerolf says...[/quote]
How do you create a hierarchy then? And what model do you use?
You can add Qt::MatchRecursive to the search flags of match and findItems.
-
Well the item root:
@
QStandardItem *root = new QStandardItem("rootItem");
model->setItem(0,root);
@The childs items
@
root->setChild(row,device2Add);
@I haven't trie with Qt::MatchRecursive, does it search too in the childs of each item?
-
Yes, MatchRecursive makes the search look into the childs too.
-
Ok, i didn't know, thanks for the advice..
-
No problem, you're welcome - and that's what this forum is meant for :-)
Just let us know, if it works out for your case.
-
yep, it works! thanks again...
-
Again, you're welcome. You can mark the post as solved now: Just hit the edit link of the original post in this thread (it's located under your avatar right of the post) and prepend "[Solved]" to the title.
-
done!