PDA

View Full Version : Paradox: QItemSelectionModel and QSortFilterProxyModel



mpi
5th October 2009, 15:08
1. I have two views on the same model. If I let the views share their selection models, then the selections between the two views are in sync.

2. To make everything even smarter, I implement my own selection model that inherits from QItemSelectionModel.

3. Then I decide that I want sort functionality in one of the views. So this view then uses a QSortFilterProxyModel.

4. But then the selection model can no longer be shared between the two views, since each view have two different model: The original and a proxy to the original.

5. As a result, selections are no longer in sync.

What a I doing wrong?

caduel
5th October 2009, 15:37
you have summed that up nicely.
you are doing nothing wrong.

Using two different models means you can not use the same selection model.
You have to keep selections in sync manually, I guess.

d_stranz
18th November 2009, 23:14
But wait - QAbstractProxyModel has mapSelectionFromSource() and mapSelectionToSource() methods. Aren't these supposed to be used to cover this problem?