How to make QSortFilterProxyModel search through children in a treeWidget?
Hey all,
I´m using a QSortFilterProxyModel to search through my QtreeWidget like this:
Code:
sourceModel = ui.treeWidget->model();
proxyModel->setSourceModel(sourceModel);
ui.treeWidget->QtreeWidget::setModel(proxyModel);
proxyModel
->setFilterRegExp
(QRegExp(".png", Qt
::CaseInsensitive,
QRegExp::FixedString));
The problem is that as the documentation says:
"For hierarchical models, the filter is applied recursively to all
children. If a parent item doesn't match the filter, none of its
children will be shown."
I would like all parent items to be shown as long as one of their
children match the filter or of course if the parent itself matches
the filter. Kind of like how the collection tab in amarok works. Any
idea how could I do that?
thanx in advance
Pat
Re: How to make QSortFilterProxyModel search through children in a treeWidget?
Reimplement either the sort proxy model or the abstract one and implement the functionality yourself. You'll probably want to cache the results as you have to be searching bottom-up and not top-down and it is more time consuming.