I am new to Python and QGIS. I want to populate the comboBox with the first column of the table attribute of the park's layer
Code:
#Populate park's comboBox
park = layers[0].layer()
park.startEditing()
for p in park.getFeatures():
self.dlg.comboBox_2.addItem(p.attributes()[0])
Error:
2022-01-03T01:39:23 WARNING Traceback (most recent call last):
File "C:/Users/ADS/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\urban_parks\urban_parks.py", line 217, in run
self.dlg.comboBox_2.addItem(p.attributes()[0]) TypeError: arguments did not match any overloaded call: addItem(self, str, userData: Any = None): argument 1 has unexpected type 'int'
addItem(self, QIcon, str, userData: Any = None): argument 1 has unexpected type 'int'
startEditing
. In fact, you probably should avoid it.