QSqlTableModel * model=new QSqlTableModel (this, db);
The model - & gt; SetTable (tableName);
The model - & gt; SetFilter (tr (limit 0, 1=1 "% 1"). Arg (rowNumber));
The model - & gt; SetEditStrategy (QSqlTableModel: : OnManualSubmit);
The model - & gt; The select ();

QTableView view=new QTableView (this);
The view - & gt; SetModel (model);
The view - & gt; SetSelectionMode (QAbstractItemView: ContiguousSelection);
//submit save
The model - & gt; The database (). The transaction ();
The model - & gt; RevertAll ();
If (model - & gt; SubmitAll ())
{
The model - & gt; The database (). The commit ();
}
The else
{
The model - & gt; The database (). The rollback ();
QMessageBox: : warning (this, tr (" Cached Table "),
Tr (" The database reported an error: % 1 ")
. Arg (model - & gt; LastError (). The text ()));
}
Ask, I just want to save, I modify the data, is what a list of all become the same value, click save
CodePudding user response:
Top, no one encountered this problem?CodePudding user response:
Haven't met, carefully check procedure, the feeling which place should be write wrong