hi guys,I had to ask for help.thanks advance!
my problem is the removeRow method in mycode never succeed:
model->setQuery("select * from person");
view->setModel(model);
QSqlQueryModel *model;
model->setQuery("select * from person");
QTableView *view = new QTableView;
view->setModel(model);
To copy to clipboard, switch view to plain text mode
ok,I can get 7 rows from the person table.
now I try
model->removeRow(0);
model->removeRow(1);
...
model->removeRow(0);
model->removeRow(1);
...
To copy to clipboard, switch view to plain text mode
however,It donse't work。everything in the view still stay.
but if I use the flowing code:
plainModel.setTable("person");
plainModel.select();
view->setModel(&plaiModel);
plainModel.removeRow(0);
QSqlRelationalTableModel plainModel;
plainModel.setTable("person");
plainModel.select();
QTableView *view = new QTableView;
view->setModel(&plaiModel);
plainModel.removeRow(0);
To copy to clipboard, switch view to plain text mode
Ok,It works. there is 6 rows left in the view.
so ,whats my problem in my first case? how can i resolve it?
need i change any thing from QSqlQueryModel to QSqlRelationTableModel?
but I would like to use setQuery method than setTable method.
so ,give a help ,please.
thx
Bookmarks