Attention!
This is just one of my random snippets. There could be better ways.
Store featurenotify.py in ~\.qgis2\python\
Usage from Python console:
>>> import featurenotify >>> layer = iface.activeLayer() >>> feature = layer.selectedFeatures()[0] >>> feature <qgis.core.QgsFeature object at 0x0CD9BAE0> >>> feature = feature.wrap() >>> feature <qgis.core.QgsFeature object at 0x0CD9BAE0>(Wrapped)
Wrapped features will emit changed signal:
>>> def changed(name, value): ... print "{} changed to {}".format(name, value) >>> feature.notifychanged.connect(changed) >>> feature["ZValue"] = 100.00 ZValue changed to 100.00
Note: Only works if you accesss fields using []
. Setting fields using setAttribute()
will not trigger the event.