2

I need to make a date format in QGIS 3 but, in the program I need to use, QgsEditorWidgetSetup('Date',{'yyyymmdd'}), I want to get this:

here is what i want to have

But I don't know how to use QgsEditorWidgetSetup to make the date looks like above image. Can you help me, please?

xunilk
  • 29,891
  • 4
  • 41
  • 80
Pierre
  • 161
  • 5

1 Answers1

2

This is my answer:

config = {'allow_null': True,
              'calendar_popup': True,
              'display_format': 'yyyyMMdd',
              'field_format': 'yyyyMMdd',
              'field_iso_format': False}
type = 'DateTime'
setup = QgsEditorWidgetSetup(type,config)
layer.setEditorWidgetSetup(6,setup)

I found it out because of following lines:

field = layer.fields()[6]
field.editorWidgetSetup().config()
field.editorWidgetSetup().type()

Qgis shows you all info to make it on code.

xunilk
  • 29,891
  • 4
  • 41
  • 80
Pierre
  • 161
  • 5