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: Proper use of beginFilterChange()/endFilterChange()?

QSortFilterProxyModel: Proper use of beginFilterChange()/endFilterChange()?

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 59 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.
  • M Offline
    M Offline
    mjiggidyj
    wrote last edited by mjiggidyj
    #1

    When header data changes in my source model, I want my QSortFilterProxyModel to invalidate its columns filter.

    I used to do this with:

    self.sourceModel().headerChanged.connect(self.invalidateColumnsFilter)
    

    However, the docs have now listed invalidateColumnsFilter as deprecated and suggest to use beginFilterChange() and endFilterChange(Direction) instead. That's cool, but I feel a little weird about it since QAbstractItemModel doesn't have "dataAboutToChange" or "headerDataAboutToChange"-style signals to link up the beginFilter/endFilter stuff; it just has dataChanged / headerDataChanged.

    So am I okay to connect headerDataChanged() to a method in my proxy model that then calls both the begin/endFilterChange() methods? This feels out-of-order.

    self.sourceModel().headerDataChanged.connect(self.binColumnDataChanged)
    
    @QtCore.Slot(QtCore.Qt.Orientation, int, int)
    def binColumnDataChanged(self, orientation:QtCore.Qt.Orientation, first:int, last:int):
    	self.beginFilterChange()
    	self.endFilterChange(QtCore.QSortFilterProxyModel.Direction.Columns)
    
    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