PDA

View Full Version : Bad selection behavior when using custom proxy model



seed
15th January 2014, 08:59
Hi,

I have created a custom proxy model(subclass of QAbstractProxyModel) to be able show certain elements in a tree I am intrested in. The source model is s subclass of QAbstractItemModel. I have implemented mapFromSource(), mapToSource(), columnCount(), rowCount(), index(), parent(), data(), hasChildren(). When I use the proxy model in my QTreeView the result looks like I expected, but the selection behaivor does not work correctly. When I select a new row in the tree view the old selection is sometimes not updated/removed(I have attached a png file showing this). I have tested my proxy model against https://qt-project.org/wiki/Model_Test and it works fine.

Does anyone have a hint what I am missing/doing wrong? How does the selection work?
I notice if I return with an extra row when rowCount() is called everything works fine and the selection is updated correctly(model test will of course not pass since I return an invalid row).

Thanks!

seed
26th February 2014, 21:49
I got invalid index during selection since I didn't implemented the silbings() function in my proxymodel. Implementing the siblings() function solved all my issues.