daisy
daisy

Reputation: 23499

Filtering child item with QSortFilterProxyModel

I'm using QSortFilterProxyModel on a QTreeView, and I'm trying to filter both top level items and the first-level child items.

Is that possible? Seems like QSortFilterProxyModel only filter on top level items.

Upvotes: 1

Views: 998

Answers (1)

Alexis
Alexis

Reputation: 705

Could you please provide more details on what you already tried? The doc says If a parent item doesn't match the filter, none of its children will be shown, which probably explain why it seems to filter only on first level.

If your goal is to filter only specific levels of your tree, you should subclass QSortFilterProxyModel and reimplement the filterAcceptRow. This way you can specify to ignore items that do not belong to specific tree levels. See the doc for more informations.

Upvotes: 2

Related Questions