[Qgis-user] How can I call pluginA from pluginB?

John Layt jlayt at kde.org
Tue Apr 19 04:13:37 PDT 2016


On 19 April 2016 at 11:47, 荻原 <pushbonx at gmail.com> wrote:
> Hi!
> I would like to ask a question how to call different plugin from a plugin.
>
> I made two plugin using  plugin builder .
>
> when I want to use plugin, I click plugin Icon in toolbar or menu,and
> the main window open.
> (That plugin is dockwidget plugin)
>
> I would like to do that from plugin.
> when I click  one button in pluginA , pluginB Main Window Open,That's it.
>
> If anyone know that solution, please help me .
> thank you for reading my question.

A few options:
1) Write it as one plugin that installs both buttons, then you have
one shared code base and installation that you can reliably share the
code between.
2) Have two plugins that both import a library with the shared code
(but then you have two copies of the code installed)
3) Import the plugin A code from plugin B, checking first that the
file exists (i.e. the plugin A is installed)
4) Use QgisInterface to find the QAction that you installed for plugin
A and trigger that

Option 1 is probably best, option 3 probably the easiest from where you are now.

John.



More information about the Qgis-user mailing list