Ok. The simplest (and probably most inefficient) solution is:
  1. disconnect model from QTableView
  2. setup filter twice
  3. connect model to QTableView


So updateFilter() in my example now looks like this:

Qt Code:
  1. void ModelTest::updateFilter()
  2. {
  3. bool modelIsEmpty = (model->rowCount() == 0);
  4.  
  5. if(modelIsEmpty)
  6. ui.tableView->setModel(0);
  7.  
  8. model->setFilter(QString("f1 = '%1'").arg(ui.lineEdit->text()));
  9.  
  10. if(modelIsEmpty){
  11. model->setFilter(QString("f1 = '%1'").arg(ui.lineEdit->text()));
  12. ui.tableView->setModel(model);
  13. }
  14. }
To copy to clipboard, switch view to plain text mode