View Full Version : QSortFilterProxyModel fixed string filtering

23rd May 2018, 06:56
I implemented filtering on a QAbstractTableModel using an out-of-the-box QSortFilterProxyModel and the method QSortFilterProxyModel::setFilterFixedString(). Based on what was in the source table model and my filter string, I kept getting too many results.

Finally resorting to qDebug(), I discovered to my surprise that the filtering was selecting every index that contained the filter string, not those that were an exact match. I would have expected that for searching a fixed filter string, exact matching should be the behavior.

Has this been the behavior all along, or has something been broken? Using Qt 5.9.

I finally resorted to using a QRegExp filter with a reg exp that forced exact matching to my string.

27th May 2018, 09:38
There was no change since Qt4: http://code.qt.io/cgit/qt/qt.git/tree/src/gui/itemviews/qsortfilterproxymodel.cpp#n2240

27th May 2018, 21:41
Thanks, I see. I guess my interpretation of the term "fixed string" is different from that of the implementers.