I’m using QTreeView and two QSortFilterProxyModel-based filters.
I need to fetch list of currently displayed items in the QTreeView, so I take selected indices (via ->selectionModel()->selectedIndexes()), pass them into simple recursive function but always get SIGSEGV. On debug I’ve found where calls stack ends — it’s somewhere in QVector::fill.
Maybe I’m doing someting wrong? If I pass indexes through mapToSource() I get ALL items, not just displayed ones.
Iterator function is simple:
void CollectionTreeWidget::iterator(const QModelIndex & index, QModelIndexList & items)
{
int count = p->dateFilterProxy->rowCount(index);
for (int i=0; i<count; i++) {
QModelIndex t = index.child(i, 0);
iterator(t, items);
}
}
Here dateFilterProxy is a model that’s used as QTreeView model. Code crashes on rowCount call.
I think I’ve found error in the algorithm above, to eliminate segfault we must not count sub-indexes for the index-leaves (i.e. nodes without children).