PDA

View Full Version : QSortFilterProxyModel over a QSystemFileModel does not dynamicaly Sort/Filter



Guett_31
4th August 2013, 03:41
Hi,

I'm trying use a QSortFilterProxyModel over a QSystemFileModel so only the files with a particular file extension will show in my view.
I've created a very simple QSortFilterProxyModel sub class to do the job.

The problem is that it filters only once when the model is set and any subsequent changes in the model layout (directory expansion in the view) won't trigger a new filtering in the proxy model.

In Qt5, the dynamicSortFilter property is set to true by default. The doc does not say much about it but I have read from other sources that QSortFilterProxyModel is supposed to respond to the layoutChanged() signal of the source model.
That signal is emitted by QSystemFileModel anytime the expansion of a new directory is requested by the view. Therefore, it should work.

One other thing that the doc says is : "you should not update the source model through the proxy model when dynamicSortFilter is true." I'm not sure if my case falls under that condition or not.
All the source model update happens in the QSystemFileModel, but the update request goes through the proxy since it is originated from the view. I'm confused about that statement.

Could someone help me with that?

Thanks!