[Qt-interest] Problem with QSortFilterProxyModel
Noah
noah at pcc.com
Wed Oct 7 17:05:01 CEST 2009
bharath.narayan at nokia.com wrote:
> Yes, I have a view and a delegate which can handle a QStringList.
>
> I guess I will have to implement QSortFilterProxyModel::filterAcceptsRow where I check for the role currently enabled.
> In which case, I can't use the `filterRole' property from QSortFilterProxyModel. I will have to define my own property which
> can hold multiple roles (Unlike filterRole, which can't handle bits). Am I correct in saying this?
That sounds right. Your implementation will need special handling of
data with the type QStringList as well, since the default implementation
simply uses QVariant::toString, which would return an empty string.
>
> Well in this case I think there's a bug here. The proxy model isn't updating itself when I add a new row to my source model.
> i.e., the filter that I have applied, doesn't reflect the newly added it.
> For example, if I am filtering based on text 'te' and there's a row which has text 'other'. Now programatically/through a menu option
> I add another item which has text 'other' into the source model (i.e., a new QModelIndex). The view doesn't update to show the newly added item,
> which means that the proxy model doesn't know about the source model's new item. Hence I added this.
> Note that I have also set the dynamicSortFilter property to true. Inspite of this, it didn't work.
I don't see this issue on 4.5.2 with dynamicSortFilter set to true.
Good luck,
Noah
More information about the Qt-interest-old
mailing list