QTreeView: Inserting row to model breaks sorting (QSortFilterProxyModel).
-
wrote on 27 Feb 2012, 13:28 last edited by
Hi,
I have QTreeView with own QAbstractItemModel implementation, sorted by custom QSortFilterProxyModel.
Everything works fine, but when I insert new row to original model, sorting goes wrong. New item is added correctly, but it's not sorted until user 2x click to TreeView header...
TreeView setSortingEnabled is true, dynamicSort is true too.
beginInsertRows(), endInsertRows() is called, emit dataChanged() from setData ......But: when i emit layoutAboutToBeChanged() and layoutChaged() signals, application asserts in qsortfilterproxymodel.cpp on line 193 (function index_to_iterator).
EDIT: it is not assert, iterator node is 0.What's wrong? Thank You for any answer...
-
wrote on 28 Feb 2012, 07:55 last edited by
Did you check if your model is sane with the "model test":http://developer.qt.nokia.com/wiki/Model_Test tool? I know tree models can be particulary hard to get right, and a tool like this (I think there are other versions around in KDE that are even more advanced) is invaluable to help you get it right.
-
wrote on 28 Feb 2012, 08:38 last edited by
Yes I tried this test and it was ok. Maybe, this problem is kind of special case.
Official example "editabletreemodel" adjusted to using QSortFilterProxyModel have this issue too (new inserted items are not sorted).
-
wrote on 28 Feb 2012, 08:41 last edited by
Interesting... Perhaps you should file a bugreport agains QSFPM?
1/4