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

Is there a way to add a combobox to a toolbar for QGIS? So far I can only find examples that add buttons.

I found this tutorial which seems to explain how to do this with general PyQT but haven't had any luck at all doing this with QGIS. So any help or guidance would be greatly appreciated.

share|improve this question
up vote 6 down vote accepted

I have achieved it by adding the following to the initGui method of my main python file.

self.toolBar = self.iface.addToolBar("My Toolbar")
self.toolBar.setObjectName("My Toolbar")

self.projCombo = QComboBox(self.iface.mainWindow())
self.projCombo.addItem('item 1')
self.projComboAction = self.toolBar.addWidget(self.projCombo)
self.projCombo.setToolTip("My Combo Box")
share|improve this answer
Literally just reading a tutorial on the addWidget function. Exactly what I needed and works fine. Thank you very much – Dan Feb 6 '13 at 14:39
@James S Thanks to your answer, I've managed to add a list of my layers to the combo box. Strange thing is, the combo box isn't populated unless I reload the plugin. Any ideas?… – user25976 Apr 22 '14 at 18:09

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.