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. How to get model index from QSortFilterProxyModel's index
Qt 6.11 is out! See what's new in the release blog

How to get model index from QSortFilterProxyModel's index

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 4.5k Views 1 Watching
  • 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.
  • T Offline
    T Offline
    tokafr
    wrote on last edited by
    #1

    Hello
    So, I have QSortFilterProxy model and when I filter the list and select the result I want to delete it. to delete the item I need the index in the my model class(QAbstractListModel) but here I have the index in QSortFilterProxy.

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      QSortFilterProxy forwards all calls to your actual model with the mapped /corrected) index.
      So you either can implement QAbstractItemModel::removeRows().
      Or directly use QSortFilterProxyModel::mapToSource() to map from a proxy model index to your model's index.

      --- 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
      • N Offline
        N Offline
        nitishjo
        wrote on last edited by
        #3

        Firstly please elaborate a little code.
        And I think there is a Method QSortFilterProxyModel::mapFromSource which may return the index you want.

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tokafr
          wrote on last edited by
          #4
          • raven-worx *
            Ok, thanks it works
          1 Reply Last reply
          0
          • N Offline
            N Offline
            nitishjo
            wrote on last edited by
            #5

            Please comment on the post as solved if the issue is solved.

            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