I am creating a plugin using QT Designer and QGIS 2.18. Using Plugin Builder along with examples I have been able to create a combo box that list all current layers in QGIS. I only want to list point layers. From hours of research I keep reading similar threads saying to use custom QT widgets like QgsMapLayerComboBox. But this is where I get confused.
Are these Qgs widgets added into QT Designer in some manner? Or in my script.py directly? Then I read one has to edit the ‘dialog_base.ui’ every time I make change in QT Designer? Can someone lead me on how to filter the combobox below to only view point layers?
Here is my code:
def run(self):
"""Run method that performs all the real work"""
layers = self.iface.legendInterface().layers()
layer_list = []
for layer in layers:
layer_list.append(layer.name())
self.dlg.comboBox.addItems(layer_list)
# show the dialog - this is needed
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.
pass



self.dlgdeclared as an instance attribute in the__init__()method. Then all ui setup should be done ininitGui()method e.g. signal slot connections, which I prefer. That way you don't have to worry about initializing and setting aFirst_startvariable. Anyway, sounds like you worked it out so all good :) – Ben W Feb 09 '20 at 23:25