I started to work with QSqlTableModel and became aware of some quirks.
First, this doesn't work:
QSqlQuery *query = new QSqlQuery("SELECT xxx FROM art WHERE art_nr LIKE '13%'");
tablemodel->SetQuery( *query );
You have to use the filter instead:
tablemodel->setFilter("art_nr LIKE '13%'");
It completely ignores the WHERE part of the query. In the Qt help it states "You should normally not call it on a QSqlTableModel. Instead, use setTable(), setSort(), setFilter(), etc., to set up the query."
Nice
I have rather complex queries involving up to 10 tables and would have preferred to write queries in a single string.
Now the important part:
I googled a bit and found some statements that tell you to not even use QSqlTableModel/QTableView and the like because they only work for very simple work and will fail to work correctly if you use multiple tables.
What are your experiences with fairly complex statemtents and updates? Should I forget QSqlTableView and implement my own (not preferred, much work)?
Bookmarks