Sunday, 4 August 2019

qgis - Referencing Qt UIs external to plugin with python



I'm developing a plugin that sets up a working environment for a user: loading layers (from db), applying styles and several custom designed (Qt) UI files etc.


Primary user interaction is in the Attribute editor (Attribute Table) where there's a mix of Autogenerated and custom designed UIs.


Some of the custom UIs contain Qt objects/widgets that I need to interact with e.g., a QPushButton and a QTabWidget with QWidgets.


Since the plugin is only setting up the working environment, letting the user work freely afterwards, how can I react to user actions/events calling python functionality?


From the following posts I get the notion that my plugin needs to act as the widgets launch platform to be able to send signals and listen on slots.



So, in short, I'm trying to interact with custom (Qt) forms external to my plugin.


How can I accomplish this?



Answer



One way would be to access you plugin from the Python Init function file defined under Layer Properties tab Fields that'a controlling your UI. Partly from The PyQGIS Programmers's Guide p. 114:



if 'pinpoint' in qgis.utils.plugins:
pp = qgis.utils.plugins['pinpoint']
pp.someMethodFromThePlugin

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...