Proxy model filtering for multiple columns
-
Hi everyone!
How to create proxy model which can filter by several columns?
First ugly solution come to my ming is:
@QSortFilterProxyModel *modelForColumn01 = new QSortFilterProxyModel(this);
modelForColumn01->setSourceModel(mainModel);
modelForColumn01->setFilterKeyColumn(1);
QSortFilterProxyModel *modelForColumn02 = new QSortFilterProxyModel(this);
modelForColumn02->setSourceModel(modelForColumn01);
modelForColumn02->setFilterKeyColumn(2);
@
but i realy don't like this solution. Is there any solutions for that? -
Subclassing "QSortFilterProxyModel":http://qt-project.org/doc/qt-5.0/qtcore/qsortfilterproxymodel.html and reimplementing "filterAcceptsRow":http://qt-project.org/doc/qt-5.0/qtcore/qsortfilterproxymodel.html#filterAcceptsRow should do the job. An example can be found here: "http://www.qtcentre.org/threads/24267-QSortFilterProxyModel-setFilterRegExp-for-more-than-1-column?p=141791#post141791":http://www.qtcentre.org/threads/24267-QSortFilterProxyModel-setFilterRegExp-for-more-than-1-column?p=141791#post141791
-
Thanks D0IT!
That's what i need :).