如何使用Qt直接从TableView或TableWidget更新数据库? 我尝试了这个,但它不起作用:
QSqlTableModel* model = new QSqlTableModel;
model->setTable( "fidels" );
model->setEditStrategy(QSqlTableModel::OnManualSubmit);
model->select();
ui->tableView->setModel(model);
来自评论:
QSqlTableModel* carte_fidelite::afficher() {
QSqlTableModel *model=new QSqlTableModel;
model->setEditStrategy(QSqlTableModel::OnRowChange);
model->setTable("fidels");
model->select();
return model;
}
cf carte_fidelite;
cf.afficher->submitall();