Results 1 to 3 of 3

Thread: Paradox: QItemSelectionModel and QSortFilterProxyModel

  1. #1
    Join Date
    Apr 2009
    Posts
    32
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Paradox: QItemSelectionModel and QSortFilterProxyModel

    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?

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Paradox: QItemSelectionModel and QSortFilterProxyModel

    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.

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Paradox: QItemSelectionModel and QSortFilterProxyModel

    But wait - QAbstractProxyModel has mapSelectionFromSource() and mapSelectionToSource() methods. Aren't these supposed to be used to cover this problem?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.