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. QSortFilterProxyModel and custom hierarchical mode and mapToSource / mapFromSource Implementation

QSortFilterProxyModel and custom hierarchical mode and mapToSource / mapFromSource Implementation

Scheduled Pinned Locked Moved General and Desktop
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.
  • P Offline
    P Offline
    prady_80
    wrote on last edited by
    #1

    This is in general a question from someone who is very new to model view programming.

    From the Qt examples, I have implemented a custom hierarchical model to display in a QTreeView using logic similar to the one used in Simple Tree model example. I want hide certain rows in the tree based on a criteria that I obtain from the Qt::DisplayRole.

    I plan to use a model derived from QSortFilterProxyModel and implement filterAcceptsRow method.
    However I have read on forums that the QAbstractItemModel derived indexes are not compatible with QSortFilterProxyModel Indexes.

    To make them compatible I need to implement mapToSource and mapFromSource methods respectively.
    I have no idea or hint as to what should go in there? How to map parent of proxy to model's proxy or as is the case with children.

    Could someone provide me with a hint or help or any direction???
    Any other functions that I need to implement considering the model in the Qt example???

    Thanks in advance.

    1 Reply Last reply
    0
    • P Offline
      P Offline
      pritamghanghas
      wrote on last edited by
      #2

      If you goal is to just filter out some rows, you don't have to reimplement those functions. Those are used only when layout of your proxy is different than your source model, like converting a list model to a table model. If you face any problem let us know.

      1 Reply Last reply
      0
      • P Offline
        P Offline
        prady_80
        wrote on last edited by
        #3

        That should not be the case. The Proxy model has its own indexes and during translation from source to proxy it does a std::stablesort. It would really be helpful if you could point me to an example. I may be wrong as I am naive in MV programming. Please let me know.

        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