Results 1 to 3 of 3

Thread: QDateTimeEdit

  1. #1
    Join Date
    Mar 2006
    Posts
    7
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QDateTimeEdit

    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?

    Qt Code:
    1. model->database().transaction();
    2. qDebug() <<"saveWidgetData: datachanged"<< datachanged;
    3. //get each field's values and save.
    4. record = model->record(recid.row());
    5. //where recid is the QModelIndex
    6. record.setValue(QString("description"),descriptionTextEdit->toPlainText());
    7. record.setValue(QString("date"),dateDateTimeEdit->property("dateTime"));
    To copy to clipboard, switch view to plain text mode 


    then insertRecord, etc. The description is saved, new record is made, etc. No errors are reported. I've tried
    Qt Code:
    1. record.setValue(QString("date"),dateDateTimeEdit->property("dateTime"));
    To copy to clipboard, switch view to plain text mode 

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

  2. #2
    Join Date
    Mar 2006
    Posts
    7
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QDateTimeEdit

    Oops. the second line of code should be:

    Qt Code:
    1. record.setValue(QString("date"),dateDateTimeEdit->dateTime());
    To copy to clipboard, switch view to plain text mode 

    Derek

  3. #3
    Join Date
    Mar 2006
    Posts
    7
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QDateTimeEdit

    Ignore this, I had the wrong field name.

    Sorry

    Derek

Similar Threads

  1. Highlighting selected section on QDateTimeEdit
    By Yorma in forum Qt Programming
    Replies: 4
    Last Post: 3rd May 2013, 12:03

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.