Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. selection update on model sorting/re-ordering with Qt

selection update on model sorting/re-ordering with Qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
mvcproxymodelsortselection
3 Posts 2 Posters 1.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JulienLopez
    wrote on 7 Jul 2016, 15:43 last edited by
    #1

    I'm trying do redefine a proxy model that can do sorting and re-ordering (the user can order each row as he wants).

    As far as I'm aware, there's nothing straight out of the box in Qt to do that, so I'm desperately trying to make my own proxy model, inheriting QAbstractProxyModel.

    I based most of what I did on the actual code of QSortFilterProxyModel, but I'm still missing some features.

    Most important to me is the selection after sorting/reordering.

    If I use a QSortFilterProxyModel, the selection on my table view follows the sort (ie, the same item is selected), but if I use my model, it does not (the same line stays selected).

    Anyone has any idea how this behavior is done with QSortFilterModel? does it have anything to do with these weird persistent indexes I don't really understand?

    R 1 Reply Last reply 7 Jul 2016, 20:36
    0
    • J JulienLopez
      7 Jul 2016, 15:43

      I'm trying do redefine a proxy model that can do sorting and re-ordering (the user can order each row as he wants).

      As far as I'm aware, there's nothing straight out of the box in Qt to do that, so I'm desperately trying to make my own proxy model, inheriting QAbstractProxyModel.

      I based most of what I did on the actual code of QSortFilterProxyModel, but I'm still missing some features.

      Most important to me is the selection after sorting/reordering.

      If I use a QSortFilterProxyModel, the selection on my table view follows the sort (ie, the same item is selected), but if I use my model, it does not (the same line stays selected).

      Anyone has any idea how this behavior is done with QSortFilterModel? does it have anything to do with these weird persistent indexes I don't really understand?

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 7 Jul 2016, 20:36 last edited by
      #2

      @JulienLopez
      why dont you use QSortFilterProxyModel directly?

      Inherit QSortFilterProxyModel, and reimplement lessThan() method. And do the comparison based on your own sort order.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • J Offline
        J Offline
        JulienLopez
        wrote on 8 Jul 2016, 05:46 last edited by
        #3

        Yeah but the user also want to be able to reorder things as he wants, not just sort (ie, put this row here, drag all my selection at this position, invert these two rows, ...)

        1 Reply Last reply
        0

        1/3

        7 Jul 2016, 15:43

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved