Sign up ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I want to create a button and add it to the QGIS toolbar or alternatively create my own toolbar and add the button here.

A plugin should be started when the user clicks the button.

share|improve this question

1 Answer 1

You can add icons to the toolbar or menus. For more info check the pyqgis Cookbook

def initGui(self):
    # create action that will start plugin configuration
    self.action = QAction(QIcon(":/plugins/testplug/icon.png"), "Test plugin", self.iface.mainWindow())
    self.action.setWhatsThis("Configuration for test plugin")
    self.action.setStatusTip("This is status tip")
    QObject.connect(self.action, SIGNAL("triggered()"),

    # add toolbar button and menu item
    self.iface.addPluginToMenu("&Test plugins", self.action)
share|improve this answer
thank you very much! –  Cathrin Jun 21 '12 at 9:17
Then why don't you accept the answer –  Stat-R Jul 26 '12 at 3:29

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.