QGIS – Binding Custom Form with Date/Time Field in SpatiaLite Database Using Qt Designer

dateqgisqt-designerspatialitetime

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.

Best Answer

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.

Related Question