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. What class of Proxy Model should I pick in the case?
QtWS25 Last Chance

What class of Proxy Model should I pick in the case?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qsortfilterproxmodelssortmappingfilter
4 Posts 2 Posters 2.3k 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.
  • K Offline
    K Offline
    Kofr
    wrote on 10 Jul 2016, 10:27 last edited by
    #1

    hi,
    I have QAbstractItemModel where I embody tree data structure and I need a proxy model with List data structure.
    I need to find suitable proxy model class to be able to

    1. Map Souce model index from Tree to Proxy Model index which converts tree index to List index.
    2. Filter data by criteria
    3. Sort data by criteria.

    So far I do not understand if QSortFilterProxyModel meets this task and is it possible to reimplement QSortFilterProxyModel::mapToSource(const QModelIndex & proxyIndex) const and QSortFilterProxyModel::mapFromSource(const QModelIndex & sourceIndex) const and do I have t o reimplement this.
    If you have experience with proxy models pls advice me.

    R 1 Reply Last reply 10 Jul 2016, 10:42
    0
    • K Kofr
      10 Jul 2016, 10:27

      hi,
      I have QAbstractItemModel where I embody tree data structure and I need a proxy model with List data structure.
      I need to find suitable proxy model class to be able to

      1. Map Souce model index from Tree to Proxy Model index which converts tree index to List index.
      2. Filter data by criteria
      3. Sort data by criteria.

      So far I do not understand if QSortFilterProxyModel meets this task and is it possible to reimplement QSortFilterProxyModel::mapToSource(const QModelIndex & proxyIndex) const and QSortFilterProxyModel::mapFromSource(const QModelIndex & sourceIndex) const and do I have t o reimplement this.
      If you have experience with proxy models pls advice me.

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 10 Jul 2016, 10:42 last edited by
      #2

      @Kofr
      actually in your case you need to reimplement the whole logic by yourself, since you want to merge different data sources and map tree structure to a list structure.
      A QSortFitlerProxyModel is rather a 1:1 relation to the source model. So you need to subclass QAbstractProxyModel.
      In indexes your model creates you can store an internal pointer to your internal data source which helps you identify the QModelIndex.

      --- 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

      K 1 Reply Last reply 10 Jul 2016, 12:35
      1
      • R raven-worx
        10 Jul 2016, 10:42

        @Kofr
        actually in your case you need to reimplement the whole logic by yourself, since you want to merge different data sources and map tree structure to a list structure.
        A QSortFitlerProxyModel is rather a 1:1 relation to the source model. So you need to subclass QAbstractProxyModel.
        In indexes your model creates you can store an internal pointer to your internal data source which helps you identify the QModelIndex.

        K Offline
        K Offline
        Kofr
        wrote on 10 Jul 2016, 12:35 last edited by
        #3

        @raven-worx
        Shall I reimplement mapSelectionFromSource() and mapSelectionToSource() in case of Converting tree to List?
        Is it enough to impementat just index mapping methods?
        I really spend so much time with Qt documentation. It is unclear.

        R 1 Reply Last reply 10 Jul 2016, 14:01
        0
        • K Kofr
          10 Jul 2016, 12:35

          @raven-worx
          Shall I reimplement mapSelectionFromSource() and mapSelectionToSource() in case of Converting tree to List?
          Is it enough to impementat just index mapping methods?
          I really spend so much time with Qt documentation. It is unclear.

          R Offline
          R Offline
          raven-worx
          Moderators
          wrote on 10 Jul 2016, 14:01 last edited by
          #4

          @Kofr
          mapFromSource() and mapToSource() are enough. The default implementation should depend on these methods only.

          --- 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

          2/4

          10 Jul 2016, 10:42

          • Login

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