Solved how to find a qtreewidgetitem by a member variable??
-
i have created a qtreewidget for showing folders using custom qtreewidgetitem.. for each custom qtreewidgetitem, i have set a member variable to store directory path.. now i want to find these items by directory path variable, not by text as QTreeWidget::findItems() provides.. how can i implement such feature??
-
You have to walk the complete tree with the help of QTreeWidget::topLevelItemCount/topLevelItem and the QTreeWidgetItem::childCount/child functions
-
@Christian-Ehrlicher that's kinda brute force approach.. ok, i will try.
-
i used 2 vectors to hold path variables and treewidgetitem pointers seperately.. now i am finding the index of path from path variables and calling respective treewidgetitem.. it is solved.
-
@abdullahzubair109
Hi
I wondered why you needed to vectors?
Would a std::map not have been easier ?
std::map<QString, QTreeWidgetItem *> lookup; -
@mrjj thanks for the suggestion. map is better