I want to design Editor Forms in QGIS 3.4 programmatically via QGIS' Python API.

Step 1: Setting Editors and human readable names for fields works fine via calls to


Step 2: Introduce Tab boxes in my Form works as well I tried to switch to using QgsEditFormConfig.EditorLayout.TabLayout, but this does not work:

editFormConfig = layer.editFormConfig()

My question is: how can I connect editorWidgetSetup settings from step 1 with those Tab boxes, setting the order of elements and which item is on which tab box?

  • Although you stated that it doesn't work editFormConfig = layer.editFormConfig() editFormConfig.setLayout(1) layer.setEditFormConfig(editFormConfig) was finally the thing I needed to change the form config to TabLayout (Drag and Drop). I don't know why it's that complicated but thanks so much!
    – Sickboy
    Commented Mar 5, 2022 at 9:04

1 Answer 1


To awnser my own question:

First, clear the whole Editor config, and then add QgsAttibuteEditorField elements in the order you like them on the editor widget, finally saving:

rootContainer = editFormConfig.invisibleRootContainer()
editorField = QgsAttributeEditorField(fieldname, index, rootcontainer)

To get Entries on the Tab boxes, you need to create QgsAttributeEditorField items with the Tab Boxes as Parent Containers.

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.