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
Forum Updated to NodeBB v4.3 + New Features

selection update on model sorting/re-ordering with Qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
mvcproxymodelsortselection
3 Posts 2 Posters 1.7k 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.
  • JulienLopezJ Offline
    JulienLopezJ Offline
    JulienLopez
    wrote on 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?

    raven-worxR 1 Reply Last reply
    0
    • JulienLopezJ JulienLopez

      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?

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on 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
      • JulienLopezJ Offline
        JulienLopezJ Offline
        JulienLopez
        wrote on 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

        • Login

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