How to count number of visible children in a QTreeWidget
Unsolved
General and Desktop
-
Hello,
I'm trying to determine the number of visible child items in a QTreeWidget (e.g. if the bottom-level children are visible, not collapsed and hidden). So far, I've not had any luck. All elements of the tree are simple top level nodes with children.
// count a the number of visible items QTreeWidget* tree = current_tree(); int num_visible = 0; for (int ii = 0; ii < tree->topLevelItemCount(); ii++) { QTreeWidgetItem* top_item = tree->topLevelItem(ii); if (top_item->isExpanded()) { num_visible += top_item->childCount(); } }
Anyone have a simple solution?
Many thanks,
BD -
Hi,
The visualRect method comes to mind for that.