Greetings everyone. Once again I require the wisdom of the QT masters.

I have the following form with a qdatawidgetmapper linked to a table in MySQL.

Qt Code:
  1. // Setup the model to use in the mapper
  2. model = new QSqlRelationalTableModel(this);
  3. model->setTable("Orders");
  4.  
  5. model->setRelation(7, QSqlRelation("customers", "CustomerNumber", "Name"));
  6. model->setRelation(5, QSqlRelation("employee", "EmployeeNumber", "UserName"));
  7. model->select();
  8. Qt::SortOrder order = Qt::AscendingOrder;
  9. model->sort(0, order);
  10.  
  11. // Setup the mapper for the order widgets
  12. mapper = new QDataWidgetMapper(this);
  13. mapper->setModel(model);
  14. mapper->setItemDelegate(new QSqlRelationalDelegate(model));
  15. mapper->addMapping(ui->idLineEdit, model->fieldIndex("OrderID"));
  16. mapper->addMapping(ui->fullfilledCheckBox, model->fieldIndex("OrderFullfilled"));
  17. mapper->addMapping(ui->fullfilledDateEdit, model->fieldIndex("FullfieldDate"));
  18. mapper->addMapping(ui->orderDateEdit, model->fieldIndex("DateTime"));
  19. mapper->addMapping(ui->dueDateEdit, model->fieldIndex("DueDateTime"));
  20. mapper->addMapping(ui->employeeLineEdit, 5);
  21. mapper->addMapping(ui->dueTimeEdit, model->fieldIndex("DueTime"));
  22. mapper->addMapping(ui->customerLineEdit, 7);
  23. //mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit);
To copy to clipboard, switch view to plain text mode 

Then I have a checkbox which should set the date in the fullfilledDateEdit box to today's date and save it.

Qt Code:
  1. ui->fullfilledDateEdit->setFocus();
  2. ui->fullfilledDateEdit->setDate(QDate::currentDate());
  3. ui->closePushButton->setFocus();
  4. ui->fullfilledCheckBox->setDisabled(true);
  5. ui->fullfilledCheckBox->setChecked(true);
  6.  
  7. //Save the order
  8. if (saveOrder())
  9. QMessageBox::critical(this,"Update Order Error", "There was an error saving the record!", QMessageBox::Ok);
To copy to clipboard, switch view to plain text mode 

SaveOrder simply performs a model->submitall() as shown below.

Qt Code:
  1. int addOrder::saveOrder()
  2. {
  3. int currIndex = mapper->currentIndex();
  4. if ((ui->customerLineEdit->text()=="") || (ui->employeeLineEdit->text()==""))
  5. return 1; // Notify user that save was not successful
  6.  
  7. // Submit all changes to the database
  8. if(!model->submit() && (!model->lastError().text().contains("No Fields to update"))) { return 1; }
  9. else if (!itemModel->submitAll() && (!itemModel->lastError().text().contains("No Fields to update"))) { return 1; }
  10. else
  11. {
  12. mapper->setCurrentIndex(currIndex);
  13. ui->savePushButton->setEnabled(false);
  14. }
  15.  
  16. return 0;
  17. }
To copy to clipboard, switch view to plain text mode 

My problem is that when I press the checkbox the date is changed in the GUI but it does not update the value in the database. When I close the window and open it again it shows the old value.

Any ideas on why this is not working?

I tried using manualsubmit but this created other problems in that it would not update anything in the table.

Thanks in advance,

Pericles