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);
tableView->setModel(sqlModel) ...
@
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
-
to your first question: call setQuery() with the new query.
-
Thank u
-
To your second question: call setQuery() with the old query.
;-)
-
nice. Thank u very much