4

I'm working on a plugin for QGIS 3 and I'm looking for an example of how I can change the widget type by using Python code. The change should be applied to fields of a vector layer.

In the end, it should look like this:

enter image description here

1
  • 6
    You should put your solution as an answer and accept it, so other people looking for answer will more easily find it
    – J.R
    Commented Nov 15, 2019 at 15:48

1 Answer 1

1

@user117572 answered to his/her own question:

I found a solution which works:

setup = QgsEditorWidgetSetup('ValueMap', {'map': {u'Description 1': u'value1', u'Description 2': u'value2'}})
layer.setEditorWidgetSetup(3, setup)

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.