I'm developing a QGIS plugin using QtDesigner and pyqt4. I have a comboBox of my vector layers and I want to show the table of the selected layer. I used this code for my comboBox:
def run(self):
"""Run method that performs all the real work"""
allLayers = self.iface.legendInterface().layers()
allLyrNames = [lyr.name() for lyr in allLayers]
self.dlg.updateCombos(allLyrNames)
# show the dialog
self.dlg.show()
# Run the dialog event loop
result = self.dlg.exec_()
# See if OK was pressed
if result:
# Do something useful here - delete the line containing pass and
# substitute with your code.
grdLayerName = self.dlg.getGridLayer()
pass
And these two functions:
def getGridLayer(self):
return(unicode(self.GridLayerCombo.currentText()))
def updateCombos(self, items):
if len(items) > 0:
self.GridLayerCombo.clear()
for item in items:
self.GridLayerCombo.addItem(item)