I am building a plugin for QGIS and want to add a string to a created polygon. In my dialog I was able to create a ComboBox filled with 10 different strings which can be added while creating the polygon. But when I identify this object this information doesn't seem to be stored. Is there a way to connect this information to the layer? Here is what I created until now:
Objects = ['Trees on grass', 'Trees on avenue', 'Grass field', 'Green roofs', 'Cool roofs', 'Facade greening', 'Solar Panels', 'Pond/river', 'Fountain', 'Surface albedo change'] #insert this string in Combobox self.ObjectType = QComboBox() object = self.ObjectType.insertItems(0, Objects) # Add this object feature to layer for layer in QgsProject.instance().mapLayers().values(): if 'field=' + self.tr('Drawings') + ':string(255,0)' in layer.dataProvider().dataSourceUri()[-28:]: # must have its first field named Drawings, string type self.layers.append(layer) self.layerBox.addItem(layer.object)
Does anyone have a clue to enhance the last part?