PDA

View Full Version : dataChanged does not re-sort the view



alex9099
3rd October 2008, 13:36
Good day, using qt4.3

1. My configuration:

MyModel (from QAbstractItemModel)

MySortFilter (from QSortFilterProxyModel)

MyView (from QTreeView)

2. MyModel is using external data source, which is a list of items, each item has its own label, so when label is changed in external source I would like to update it in the MyView and automatically re-sort elements. At the moment, I'm emitting dataChange signal for changed indexes and MyView successfully updates these indexes. The problem is that items are not re-sorted.

3. Note, that on initial model load strings are sorted correctly and after emitting dataChange signal I can see that MySortFilter's lessThan and filterAcceptsRow are called. Moreover, I can see that layoutChange signal is received by MyView.

4. MySortFilter is using dynamic filter, enabled with setDynamicSortFilter(true)

Any suggestions?

Thanks!

yuriry
3rd October 2008, 21:39
I have a similar setup, except I do not sub-class QSortFilterProxyModel and QTreeView and use them directly. The sorting works as expected in all cases, including inserting, removing and re-naming the items.

What happens when you insert a new item? Is the view re-sorted properly?

alex9099
5th October 2008, 21:14
Problem is solved, was due to error in ::parent() model's method.