5

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

3

Solved by :

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

Thanks !

1

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)

Your Answer

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

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