I'm trying to make an edit form in QGIS (Python code) ,and i want after feature drawing to get the id, and the feature to be selected.
Do you have any ideas to do that?
Tried so far:
self.iface.activeLayer().featureAdded.connect(self.myfonction)
def myfonction(self):
for feat in self.iface.activeLayer().getFeatures():
self.iface.activeLayer().setSelectedFeatures([feat.id()])
Best Answer
From the doc, it seems that
featureAdded
sends the feature id as argument. You can replacedef myfonction(self)
withdef myfonction(self, fId)
and usefId
in your function.