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. Indexing not ordered data model - proxy

Indexing not ordered data model - proxy

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 338 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.
  • A Offline
    A Offline
    anyfun
    wrote on last edited by
    #1

    Hello everyone,

    I'm trying to build my first application based on Qt. I have discovered the whole pattern of Model/View/Delegate (+proxy) and I do my best to build the application with the best Qt practices.

    I have unfortunately not found any topic that answers exactly my problem.

    My situation is the following (shortened on purpose) :

    • AbstractTableModel (based on a Python dictionary)
    • SortFilterProxyModel (subclassed to have 3 filters working together)

    I'm looking for a reliable way to have correct read/write accesses to my model.
    I am aware of the following information : Model subclassing reference.

    Even if I feel like these are dirty ways to solve it and I am obviously missing something, I have tried two solutions that didn't work:

    • Intermediate dictionary to make the link between my data model key and its row. This does not work because if you are using a proxy the index.row() may come from 2 different models : the proxy and the data model. The row indicated by the proxy is not relevant to the data model. Also, mapToSource seems to work only on pointer in the QModelIndex not the row/column.

    • Intermediate dictionary to make the link between my data model key and a internalId QModelIndex generated when the data is set in the data model. This does not work because when the proxy filters, it uses filterAcceptsRow with a row as parameter. Then, you need to regenerate an index that does not appear in the intermediate dictionary and you cannot gather the correct row/column.

    Come the question:

    • How do you handle not ordered data model with proxy ?

    Thanks you for your reading and your time.

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by SGaist
      #2

      Can you explain more concretely what the problem is and what you have?

      • Did you subclass QAbstractTableModel?
        • Did you run your subclass through the model test?
      • Did you subclass QSortFilterProxyModel?
      • What specific problem are you facing?

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      2

      • Login

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