tags:

views:

259

answers:

1

I have a normal QTreeView, a custom QAbstractItemModel and a custom QSortFilterProxyModel.

I've reimplemented QSortFilterProxyModel::filterAcceptsRow to filter items from my model in the way I want, however now I want those filtered items to be expanded in the treeview.

The obvious solution was to emit a signal from QSortFilterProxyModel::filterAcceptsRow() when an accepted item was found, then connect that signal to the QTreeView::expand().

However, QSortFilterProxyModel::filterAcceptsRow() is const, so I cannot emit a signal from inside that method. QSortFilterProxyModel doesn't have any other signals that would aid me.. and I am beginning to think I will have to subclass QTreeView, which I'd rather not do (less code == better).

So, is there any way to autoexpand those items that the filtermodel accepts?

+1  A: 

QTreeView has a "expandAll" slot, which could be called after you set the model. I would think that this should do what you want.

Caleb Huitt - cjhuitt