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

At the end it should look like that:

enter image description here

I found a solution which works:

setup=QgsEditorWidgetSetup( 'ValueMap', {  'map': {u'Description 1': 
u'value1',  u'Description 2': u'value2'} } )
layer.setEditorWidgetSetup(3, setup)
  • 5
    You should put your solution as an answer and accept it, so other people looking for answer will more easily find it – J.R Nov 15 at 15:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.