Re: QSqlTableModel::setQuery
try using QSqlQueryModel or call QSqlTableModel::setFilter(), only passing the where clause
Re: QSqlTableModel::setQuery
Quote:
Originally Posted by
caduel
Thanks, but I don't think either will work for my purposes.
I'm looking for a solution that provides read&write access to the table view (that nixes QSqlQueryModel). And I'd like to use an SQL query that joins more than just one table. I think that eliminates setFilter(). eg:
SELECT foo.name FROM foo, bar WHERE foo_id = bar_id;
I was hoping that I could pass a query like this to the table model's setQuery() method, "filtering" the records displayed in the table view and maintaining read&write access. My attempts so far are erroneously displaying all rows, rather than those that satisfy the where clause. (Note that my test query yields correct results from the cmd-line.)
Re: QSqlTableModel::setQuery
Could you achieve the filtering using a QSortFilterProxyModel on top of your QSqlTableModel ?