I have written a few QGIS plugins based on dockwidget (Spectre Viewer and Stripchart viewer). When opened, the plugin window is expected to stay open and react to interactions with opened layers. This works fine, but an annoyance is that when the plugin is installed and active, its window will open as soon as I start QGIS. I do not want them to appear until I open the plugin from the menu or toolbar. How can I do this?
The problem seems to be the opposite of QGIS plugins open automatically when starting QGIS, but I cannot see how the answer to this could help me (I do not have any startup.py in my plugins)
Best Answer
I made the following edits to your plugin's
qgisSpectre.py
file in my local installation which seem to have fixed the problem. You can make the same changes in your local installation to test, then update your plugin.Move the line which creates the dialog instance from the
initGui()
method to the__init__()
method and add the following lines like so:Also in the
__init__()
method, change:to:
Then set the
self.pluginIsActive
attribute to False in theinitGui()
method.