For a Qgis plugin I want to make a toolbar with additional buttons, which I want to dock on the vertically on left side beneath the add layers buttons I made the toolbar with in the a :

class Test:
    def __init__(self, iface):
        self.iface = iface

    def initGui(self):
        self.toolbar = self.iface.addToolBar("My tools")   
        self.iface.addToolBar(self.toolbar, area=Qt.LeftToolBarArea)

To unload the plugin I used:

    def unload(self):
        del self.toolbar

The toolbar is in the proper location, however when I unload the plugin it does not delete the toolbar. And when I reload it it creates an extra instance. So, I appear to have no way to unload the toolbar. I tried assigning a variable to the second addToolBar function but it returns None. Does anyone know of a solution?

1 Answer 1


You could use the following to remove the toolbar before deleting it:

def unload(self):
    self.iface.mainWindow().removeToolBar( self.toolbar )
    del self.toolbar
  • @StefVerdonk - Most welcome, glad it worked :)
    – Joseph
    May 11, 2017 at 10:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.