I am trying to get a QSortFilterProxyModel to filter a table based on two inputs. The first input is a string that can have wildcards in it while the second one is a dropdown which shows the names of all the columns in the table.
When the user enters a string in the first input and selects a column I call the model and set the QSortFilterProxyModel in the way shown below.
Qt Code:
// Find button pressed qDebug() << "Searching for " << searchValue << "from" << ui->fromComboBox->currentIndex() << "!!!"; if (!searchValue.isEmpty()) { model->setTable("Products"); model->select(); filterModel1->setSourceModel(model); filterModel1->setFilterRegExp(searchValue); filterModel1->setFilterKeyColumn(ui->fromComboBox->currentIndex()); filterModel1->setFilterCaseSensitivity(Qt::CaseInsensitive); ui->tableView->setModel(filterModel1);To copy to clipboard, switch view to plain text mode
This does not seem to show anything in the tableview. Could anyone help me by identifying what I am missing?
Thanks,
Pericles
Added after 19 minutes:
It seems that every time I ask a question the solution comes to me immediately afterwards.
I am sorry for posting questions and answering them a few minutes later. It seems that I need to trust myself to find the answer a little longer.
I solved this by changing the
filterModel1->setFilterRegExp(searchValue);
to
filterModel1->setFilterRegExp(QRegExp(searchValue, Qt::CaseInsensitive, QRegExp::FixedString));
This seemed to do the trick even though I think I tried this before but something else must have been the problem.
Thanks and sorry for the redundant post.
Pericles
Bookmarks