PDA

View Full Version : Find out when filtering is doing in QSortFilterProxyModel



alizadeh91
25th February 2013, 12:59
Hi guys..
I’ve used a QSortFilterProxyModel. Now in filtering the tableview (by setFilterRegExp), I want to be warned. But there isn’t nothing such signal in QSortFilterProxyModel that emitted in this case. How can i find out when the filtering is doing?!

Ashkan_s
26th February 2013, 14:33
You can subclass QSortFilterProxyModel and override QSortFilterProxyModel::setFilterRegExp (http://qt-project.org/doc/qt-4.8/qsortfilterproxymodel.html#filterRegExp-prop) to emit a signal when it is called.

alizadeh91
26th February 2013, 14:35
yes that is the only way!

wysota
26th February 2013, 19:47
yes that is the only way!

No, it is not. You can make use of filterAcceptsRow() or filterAcceptsColumn(). Overriding setFilterRegExp doesn't make much sense because it is not a virtual method.

alizadeh91
26th February 2013, 21:50
You mean that i override the filterAcceptsRow() ?

wysota
26th February 2013, 22:00
You mean that i override the filterAcceptsRow() ?

Yes. And detect a change in filter settings. Be aware though that this will make your proxy model much slower.