1

I am developing a plugin which allows the user to edit the features attribute information. I have a combo box from which user can select the layer name for which attributes are to be edited. I need to add field names of layer selected in combo box as labels along with empty line edit boxes. How this can be done?

layers = self.iface.legendInterface().layers()
    layer_list = []
    for layer in layers:
        layer_list.append(layer.name())
    self.dlg.comboBox.addItems(layer_list)
    selectedLayerIndex = self.dlg.comboBox.currentIndex()
    selectedLayer = layers[selectedLayerIndex]
    fields = selectedLayer.pendingFields()
    fieldnames = [field.name() for field in fields]

Something like this enter image description here

1

I don't know there is need to create such thing, cuz it already exists.

As far as I understand you want this:

iface.getFeatureForm(layer, feature)

Here you have more info about it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.