I am working on a plugin in QGIS and want to get a signal when the geometry to a feature(in this case a polyline) in my layer is changed. For example if I use the node tool to drag one of the nodes.
In the qgis-api-documantion(http://qgis.osgeo.org/api/classQgsVectorLayer.html) i see that the line:
void geometryChanged (QgsFeatureId fid, QgsGeometry &geom) is listed under signals.
So I used this command: QObject.connect(self.iface.activeLayer(),SIGNAL("geometryChanged(QgsFeatureId, QgsGeometry)"),self.changedGeometry)
I have a method called changedGeometry:
def changedGeometry(self, intValue, qgsGeom): QMessageBox.information(self.iface.mainWindow(),"Message", "Changed geometry. intValue: " + str(intValue) + "qgsGeom: " + str(qgsGeom)) When executed I get this error:
TypeError: C++ type 'QgsFeatureId' is not supported as a slot argument type I have also tried QObject.connect(self.iface.activeLayer(),SIGNAL("geometryChanged(int, QgsGeometry)"),self.changedGeometry).
Then the program do not crash, but I don't get the message about changed geometry
I am using QGIS version 1.8.0-Lisboa. Compiled against Qt 4.7.1 and these
import statements are in the top: from PyQt4.QtCore import * from PyQt4.QtGui import * from qgis.core import * from qgis.gui import * Edit: I tried using qint64 instead QgsFeatureId, but it still don't work.
QObject.connect(self.iface.activeLayer(),SIGNAL("geometryChanged(qint64,QgsGeometry)"),self.changedGeometry)
Edit2: I also tried using the new style of connecting signals and slots. self.iface.activeLayer().geometryChanged.connect(self.changedGeometry) But it gave me this error message:
TypeError: connect() failed between geometryChanged(qint64,QgsGeometry) and unislot()