PDA

View Full Version : QDateTimeEdit



dkite
10th September 2006, 20:07
I have a QSqlRelationalTableModel with a mysql driver, a tableview that shows the table which works. I am trying to add and edit records in a dialog with the fields for editing. I can transfer the data fine, but have a problem:

How do I save the data from a QDateTimeEdit?


model->database().transaction();
qDebug() <<"saveWidgetData: datachanged"<< datachanged;
//get each field's values and save.
record = model->record(recid.row());
//where recid is the QModelIndex
record.setValue(QString("description"),descriptionTextEdit->toPlainText());
record.setValue(QString("date"),dateDateTimeEdit->property("dateTime"));



then insertRecord, etc. The description is saved, new record is made, etc. No errors are reported. I've tried

record.setValue(QString("date"),dateDateTimeEdit->property("dateTime"));

with the same results. The date isn't inserted into the table. Any ideas?

dkite
10th September 2006, 20:09
Oops. the second line of code should be:


record.setValue(QString("date"),dateDateTimeEdit->dateTime());

Derek

dkite
10th September 2006, 20:12
Ignore this, I had the wrong field name.

Sorry

Derek