[Development] QSortFilterProxyModel: recursiveFilteringEnabled

László Papp lpappyt at gmail.com
Wed Sep 20 20:31:05 CEST 2023


Yes, I have tried that, thanks.

bool TableProxyModel::filterAcceptsRow(int sourceRow,
                                       const QModelIndex &sourceParent)
const
{
  QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
  CustomModelItem* item =
static_cast<CustomModelItem*>(index.internalPointer());
  return !item->childCount();
}

The problem is the property. It is mixing two different things, so it does
not suffice when one only needs one of those.

If you filter without recursiveFilteringEnabled enabled (default, false),
then it will only filter through the root node(s). So, you would not be
able to filter in the children.

If you set recursiveFilteringEnabled to true, then it will filter through
the children, but then it will also include the parents of those children.

So, what we need is being able to filter through children (i.e. recursive
filtering), but without showing the parents.

Does that make sense?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20230920/a58526ff/attachment.htm>


More information about the Development mailing list