PDA

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



alizadeh91
25th February 2013, 13: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, 15: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, 15:35
yes that is the only way!

wysota
26th February 2013, 20: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, 22:50
You mean that i override the filterAcceptsRow() ?

wysota
26th February 2013, 23: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.