I've been following this thread in attempts to configure my ui preferences programmatically. I've had no issues with loading styles (which subsequently sets the custom ui if I saved it this way), but I am unable to setEditForm solely. The following things do not work (result is that the properties stay on Autogenerate default option) both in the python console and in my plugin. I've tried with both QGIS 2.0 and 2.4.

layer.setEditForm('C:/my/full/pathname/with spaces/form.ui')

1 Answer 1


There's a small paragraph in the linked answer that says that you will also have to use QgsVectorLayer.setEditorLayout( QgsVectorLayer.EditorLayout ) to set the layout but it's not very obvious that it's connected to your problem.

Applied to your case this means

layer.setEditorLayout( QgsVectorLayer.UiFileLayout )
layer.setEditForm('C:/my/full/pathname/with spaces/form.ui')


As of QGIS 2.6 the first line is no longer mandatory

  • Thank you so much for pointing that out. Your answer on the linked post was very helpful, by the way. I've been looking for more info in the API on setEditorWidgetV2 and setEditorWidgetV2Config widget type and config parameters.
    – user25976
    Jul 8, 2014 at 22:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.