running this code
MasterDialog dlg(this->master, this->details, index, this);
if(dlg.
exec() == QDialog::Accepted){
dlg.submit();
if(!this->master->submitAll()){
QMessageBox::critical(this,
"cant save data", master
->lastError
().
text());
this->master->revertAll();
this->details->revertAll();
return;
}
if(!this->details->submitAll()){
QMessageBox::critical(this,
"cant save data", details
->lastError
().
text());
this->master->revertAll();
this->details->revertAll();
return;
}
}
MasterDialog dlg(this->master, this->details, index, this);
if(dlg.exec() == QDialog::Accepted){
dlg.submit();
if(!this->master->submitAll()){
QMessageBox::critical(this, "cant save data", master->lastError().text());
this->master->revertAll();
this->details->revertAll();
return;
}
if(!this->details->submitAll()){
QMessageBox::critical(this, "cant save data", details->lastError().text());
this->master->revertAll();
this->details->revertAll();
return;
}
}
To copy to clipboard, switch view to plain text mode
changes from the details model aren't saved to the database. If you comment
if(!this->master->submitAll()){
QMessageBox::critical(this,
"cant save data", master
->lastError
().
text());
this->master->revertAll();
this->details->revertAll();
return;
}
if(!this->master->submitAll()){
QMessageBox::critical(this, "cant save data", master->lastError().text());
this->master->revertAll();
this->details->revertAll();
return;
}
To copy to clipboard, switch view to plain text mode
the details are correctly saved.
the project is attached. It uses a sqlite memory db so it should be simple to run and test it.
Bookmarks