[Qgis-user] Proper Way to Unload A Toolbar
C Hamilton
adenaculture at gmail.com
Tue Oct 25 04:58:23 PDT 2022
I see several ways developers have created custom toolbars and then removed
them and I am wondering if there is a preferred way. In the initGui of the
plugin we would have something like this:
self.toolbar = self.iface.addToolBar('My Toolbar')
self.toolbar.setObjectName('MyToolbar')
When we add an action it is:
self.toolbar.addAction(self.myAction1)
self.toolbar.addAction(self.myAction2)
In unload() I see two methods used:
Method 1:
self. myAction1 .deleteLater()
self. myAction1 = None
self. myAction2 .deleteLater()
self. myAction2 = None
self.toolbar.deleteLater()
self.toolbar = None
Method 2:
self.iface.removeToolBarIcon(self. myAction1)
self.iface.removeToolBarIcon(self. myAction2)
del self.toolbar
It is unclear to me in Method 2 whether removeToolBarIcon() applies to a
custom toolbar or not. I have used that in my plugins but am wondering if
it only is to be used if you are using the Plugins toolbar.
Thanks,
Calvin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20221025/c20212c4/attachment.htm>
More information about the Qgis-user
mailing list