QTableView & QSqlQueryModel :when query changes
-
wrote on 18 Feb 2012, 05:55 last edited by
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
-
wrote on 19 Feb 2012, 22:06 last edited by
to your first question: call setQuery() with the new query.
-
wrote on 20 Feb 2012, 05:45 last edited by
Thank u
-
wrote on 20 Feb 2012, 08:43 last edited by
To your second question: call setQuery() with the old query.
;-)
-
wrote on 20 Feb 2012, 14:22 last edited by
nice. Thank u very much
1/5