The Long Version
I have a QSortFilterProxyModel subclass that reimplements filterAcceptsRow(). In filterAcceptsRow, I check the result of various regexp's (one for each column of a tableview). Additionally, I have numerous set methods that change the value of the regexp patterns used in filterAcceptsRow() and call invalidateFilter().

In my main window, I have a QLineEdit that, upon emitting its textChanged signal sets the forementioned filters according to a specific syntax. If, for example, I have:

name=beagle; type=dog

the result set would consist of rows who's name column contains beagle and type column contains dog.

What I can't figure out, is how to remove all filters if the line edit is empty. Well, I can, but I can't help but think there must be a more correct way to do it. Here is some pseudo-code (python) that demonstrates what I've tried, and what I've ended up doing until I find a more permanent solution:

Qt Code:
  1. if len(lineEdit.text()) > 0:
  2. field = lineEdit.text().split("=")[0]
  3. pattern = lineEdit.text().split("=")[1]
  4. if field == name:
  5. model.setNameFilter(pattern)
  6. elif field == type:
  7. model.setTypeFilter(pattern)
  8. else:
  9. model.invalidateFilter() # doesn't work
  10. model.clear() # also doesn't work
  11. model.invalidate() # again, doesn't work
  12. model.setNameFilter("") # works
To copy to clipboard, switch view to plain text mode 

The Short Version
In short, what method should I be calling to get the model back to it's original state? Have I misunderstood the use of invalidateFilter? Should I be reimplementing it?

Thanks in advance for any help. I've been teaching myself python and Qt for the last month or so, and things have been fairly smooth up until now.