Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Through tutorials I learned how to add a toolbutton to the plugins-toolbar via python. Now I wonder how to add a complete toolbar with toolbarbuttons via python.

Can anybody give some example-code?

Thanks and regards

share|improve this question

You can use the addToolBar() API call via QgisInterface (i.e. iface) to create a custom toolbar:

class MyPlugin:

    def __init__(self, iface):
        # Save reference to the QGIS interface
        self.iface = iface

    def initGui(self):
        # Add toolbar 
        self.toolbar = self.iface.addToolBar("My_ToolBar")

        # Create actions 
        self.someact = QAction(QIcon(":/plugins/MyPlugin/icons/someactionicon.png"),
                               QCoreApplication.translate("MyPlugin", "My Action"),

        # Connect action signals to slots

        # Add actions to the toolbar

    def unload(self):
        # remove toolbar on plugin unload
        del self.toolbar

    def doSomething(self):
        # slot for action
share|improve this answer

I have posted an answer to a post of mine here:

How can I add a second Toolbar Button and Dialog to a QGIS plugin built with Plugin Builder?

that may also answer your question

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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