For my attribute table I created a custom form in Qt Designer. The table has a date field and a time field.

In Qt Designer there are widgets for entering date and time but what data type is expected for the fields in my attribute table in QGIS?

The values always stays NULL in every case, when I choose date, datetime or text. Under Layer properties when I choose the edit widget "calendar" there is a calendar popup even when I use my custom form.

  • What format is your data saved in? Shapefile, PostGIS table, or something else? Jan 27, 2014 at 20:42
  • in a spatialite table
    – parallax
    Jan 27, 2014 at 20:46

2 Answers 2


You need to edit the properties of yours fields Date and Time in QGIS.

  1. Go to the properties of your layer.
  2. Select the Fields tab.
  3. In the line of your field (date and time), click on Line edit.
  4. Select Date/Time.
  5. And then you can specify the format of your date or time -> it must be the same as defined in Qt Designer!

If the properties are the same in your Qt form and in the fields parameters of your layer, the binding will be done automatically.


I think it depends on the definition of your attribute table an the driver model, for example in PostgreSQL and PostGIS:

  • Date - PGSQL: Date
  • Time - PGSQL: Time
  • DateTime - PSQL: TimeStamp with or without time zone

You can find bindings of data types between the DB and Qt representation under http://qt-project.org/doc/qt-4.8/sql-programming.html.

  • Thanks for your comment. I need to know how to realize the binding between the qgis custom form and my spatialite table. I choose QDateEdit (ddMMyyyy)and QTimeEdit (HH:mm). In my spatialite table the corresponding field has the data type date and datetime. It is not clear to me how I can connect the form input with the table. The objectName in qt designer is the same as the field name in the table. But which edit widget do I choose in the qgis layer properties?
    – parallax
    Feb 2, 2014 at 17:44
  • And is therre a way to set the aktual date/time as default?
    – parallax
    Feb 2, 2014 at 17:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.