Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QTableView & QSqlQueryModel :when query changes
there is a QTableView to display query results, and I set it's model as a QSqlQueryModel:
QSqlQueryModel* sqlModel = new QSqlQueryModel();
sqlModel->setQuery(“SELECT id,title FROM tbarticle where key = '1'”, db);
Now I'd like to query key = '2',and show them on the same tableView, what should I do?
Should I reset the model of the tableview,or change it?
Another question, if I insert into the database, how should I update the view?
Looking forward to your ideas!
Edit: Please use @ tags around code sections; Andre
goetz last edited by
to your first question: call setQuery() with the new query.
andre last edited by
To your second question: call setQuery() with the old query.
nice. Thank u very much