PDA

View Full Version : QSortFilterProxyModel QAbstractItemModel



Qiieha
27th October 2012, 18:31
Hi
I have a complex QTreeView and a subclasses QAbstractItemModel. Now I want to use QSortFilterProxyModel for filtering. I have some questions:
Which methods do I have to reimplement in QSortFilterProxyModel? (mapFromSource, mapToSource)
Am I allowed to add rows and change data via the QAbstractItemModel directly?

What I have to consider?

thank you

Lykurg
27th October 2012, 20:41
You don't have to reimplement any specific method in QSortFilterProxyModel. Only if you like. A custom filterAcceptsRow() I guess, which is does your filtering.

And yes, you can change data via the QAbstractItemModel directly, but I would rather use the proxy model. Even if the proxy model watches the source model (http://qt.gitorious.org/qt/qt/blobs/4.8/src/gui/itemviews/qsortfilterproxymodel.cpp#line1557)

Qiieha
29th October 2012, 08:01
Thank you Lykurg = )