QtSqlQueryModel removeRow's problem
hi guys,I had to ask for help.thanks advance!:)
my problem is the removeRow method in mycode never succeed:
Code:
model->setQuery("select * from person");
view->setModel(model);
ok,I can get 7 rows from the person table.
now I try
Code:
model->removeRow(0);
model->removeRow(1);
...
however,It donse't work。everything in the view still stay.
but if I use the flowing code:
Code:
plainModel.setTable("person");
plainModel.select();
view->setModel(&plaiModel);
plainModel.removeRow(0);
Ok,It works. there is 6 rows left in the view.
so ,whats my problem in my first case? how can i resolve it?:confused:
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
:p
Re: QtSqlQueryModel removeRow's problem
QSqlQueryModel is a read only model, you can't remove rows from it.
Re: QtSqlQueryModel removeRow's problem
yeah, with QSqlQueryModel read only.
I want to have something ,
perhaps I have 7 rows in the table,
I just want to delete some rows from the QTableView,
not delete the record in the database,how can I do??
can u give me a point? thx
Re: QtSqlQueryModel removeRow's problem
Apply a QSortFilterProxyModel or set a condition on the query so that you only retrieve the rows you need from the database.