I'm new to QGIS python development. I'm trying to create new features in an existing vector layer and then to display the Feature Form so that the user can fill the attribute values.

The problem is, after the code is executed (after I fill the features atribute values and click Ok), an error is shown: Feature 0 for attribute update not found.

After that, I run again the code to create another feature with different attribute values. No error appears, but I notice that the attribute values from the firts created feature are exact like the attribute values from the second created feature.

Here is the code:

mylayer = QgsProject.instance().mapLayersByName('my layer name')[0]
feat = QgsFeature ()

//here is the code that creates the geometry//

self.iface.openFeatureForm(mylayer, feat, False)

What am I doing wrong? I don't know if it helps, but mylayer is an empty layer.

Your Answer

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

Browse other questions tagged or ask your own question.