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. Notifying model QSortFilterProxyModel / QIdentityProxyModel of model data change?

Notifying model QSortFilterProxyModel / QIdentityProxyModel of model data change?

Scheduled Pinned Locked Moved Solved General and Desktop
qabstractitemmoqsortfilterproxqidentityproxymqdrag drag drop
3 Posts 3 Posters 1.9k 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.
  • D Offline
    D Offline
    Dariusz
    wrote on last edited by Dariusz
    #1

    Hey

    I have

    MyModek(QAbstractItemModel)>myProxyModel(QIdentityProxyModel)>myFilterProxy(QSortFilterProxyModel) model system.

    When I perform dropMimeData on my Model I run these 2 commands :

        Q_EMIT dataChanged(newData.first()->index(), newData.last()->index()); /// data is sorted by index top to bottom
        Q_EMIT layoutChanged({p}); /// p is parentIndex node
    

    I've noticed that when I drop items that has a myFilterProxy then the new items don't show up unless I clear up the filter string and retype it in/out to have it re-read full data list from my base model. Even if the string is empty, they do not show up.

    What signal should I emit from my Model to notify the identity and filter models properly?

    TIA


    Sorted, I had to forward signals from my model to proxy then to filter with dataChanged/etc and link it to invalidate on proxy filter.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      You can call invalidate() or invalidateFilter() to tell your proxy that it needs to redo the filtering or sorting.

      (Z(:^

      innermousI 1 Reply Last reply
      3
      • sierdzioS sierdzio

        You can call invalidate() or invalidateFilter() to tell your proxy that it needs to redo the filtering or sorting.

        innermousI Offline
        innermousI Offline
        innermous
        wrote on last edited by
        #3

        You may also try to set dynamicSortFilter: true, but only if you do not modify contents of model through proxy model.
        invalidate() calls are expensive and you should only do it when you know what you are doing.
        If you modify contents of your model through proxy model and/or you need to filter and sort on demand, invalidateFilter() and sort() is what you are looking for.

        1 Reply Last reply
        3

        • Login

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