I have a signal setup for a feature deletion event on a layer:
self.layer.featureDeleted.connect(self.feature_deleted)
When I try and grab an attribute from the deleted feature on the slot, a StopIteration error is thrown (i.e it cannot retrieve the feature).
I would have thought I should still be able to retrieve attributes from a deleted feature before the changes to the layer are committed? Otherwise I don't see what use the fid parameter is.
def feature_deleted(self, fid):
feature = self.layer.getFeatures(QgsFeatureRequest().setFilterFid(int(fid))).next()
idx = self.layer.fieldNameIndex('my_attribute')
print feature.attributes()[idx]
How can I access the attributes of a deleted feature (before the changes to the layer are committed)?