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

How to get model index from QSortFilterProxyModel's index

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 4.3k 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 26 Jan 2015, 08:30 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
    • R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 26 Jan 2015, 08:45 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 26 Jan 2015, 08:53 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 26 Jan 2015, 09:16 last edited by
          #4
          • raven-worx *
            Ok, thanks it works
          1 Reply Last reply
          0
          • N Offline
            N Offline
            nitishjo
            wrote on 28 Jan 2015, 05:58 last edited by
            #5

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

            1 Reply Last reply
            0

            1/5

            26 Jan 2015, 08:30

            • Login

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