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
_______________________________________________
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to