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 13 Apr 2019, 09:41 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
    • S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 13 Apr 2019, 13:56 last edited by
      #2

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

      (Z(:^

      I 1 Reply Last reply 13 Apr 2019, 18:52
      3
      • S sierdzio
        13 Apr 2019, 13:56

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

        I Offline
        I Offline
        innermous
        wrote on 13 Apr 2019, 18:52 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

        3/3

        13 Apr 2019, 18:52

        • Login

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