6

I want a custom "QGIS 2.14.6 Essen" layer edit form in my own python plugin.

I use layer.setEditForm( NODE_ui_path ) and layer.setEditFormInit('NODE.formOpen')

Function NODE.formOpen does not work!

MyPlugin is in ~\.qgis2\python\plugins\MyPlugin

Ui Form is in ~\.qgis2\python\plugins\MyPlugin\NODE.ui

formOpen is in ~\.qgis2\python\plugins\MyPlugin\NODE.py

mgri
16.4k6 gold badges48 silver badges80 bronze badges
asked Dec 6, 2016 at 11:03

2 Answers 2

3

Solved by :

layer.editFormConfig().setInitCodeSource(1)
layer.editFormConfig().setInitFilePath(python_file_path)
layer.setEditForm(ui_file_path)
layer.setEditFormInit('formOpen')

Thanks !

ArMoraer
5,7493 gold badges27 silver badges52 bronze badges
answered Dec 6, 2016 at 13:45
3

IN QGIS 3.0

config = layer.editFormConfig()
config.setInitCodeSource(1)
config.setUiForm("ui_file.ui")
config.setInitFilePath("py_file.py")
config.setInitFunction("method_name")
layer.setEditFormConfig(config)
answered Jun 8, 2018 at 14:47

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.