Hello again Qt people,
I try to keep this as short and simple as possible, but that's not guaranteed to happen
Little bit background first, I have a model inherited from QAbstractItemModel and then I have QTreeView to show the content of the model in it (example for this have been taken from EditableTreeModel). I have made some modifications to this example to get the wanted data in the model. Also I have put the QSortFilterProxyModel wrapper around the model to get the sorting functionality working.
So the problem:
Everything seems fine at this point and I'm able to add items to the model and they pop up nice and clean to the QTreeView, as expected. Also to the right place according to the selected sorting.
When I select some item from the view I'll update my main view (which is just a widget to show the selected items data in it). As far it seems to work as it should.
Though, when I have some item selected from the view and that same item gets removed from the model I get some odd behavior. Selection is updated but it's not consistent which of the remaining item gets selected and what is even odder, the main view can be updated with different items data than which got selected. Usually the selection and main views content is updated correctly... but it seems that if the removed item is the first child of the root item, the selection and main view doesn't get updated correctly. In my model I just have the dummy root item which represents the header and it can have child items, but these root item's children don't have any children of their own, at least just now.
So the tree structure in model could look something like this:
Root Item (representing the header)
|--- Child1
|--- Child2
|--- Child3
Is there some possibility that the model indexes don't get updated correctly? Any other suggestions?
I won't post any code just yet, but if you guys could point out the direction to look the bug for, I could probably post some specific parts of the code.
-Tepi
Bookmarks