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.


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()

  • Could you actually report how you got it to work please ? I'm having a similar problem with featureDeleted, and need to stay with stable build 1.8 for now. Thanks. Commented Aug 6, 2013 at 15:32
  • They probably solved it by using the correct signature of the method in the signal text, ie "QgsFeatureId, QgsGeometry &". The missing & is important. See here the C++ signature of the method: qgis.org/api/classQgsVectorLayer.html. Not sure why QgsFeatureId would not work, but even if QgsFeautreId was fixed, the 2nd argument is still wrong in the text of this post. Commented Feb 9, 2015 at 12:22

1 Answer 1


Ok. That was a bug in the SIP bindings. Fixed in commit:32978fb4. Apparently the names of the signals have to match in python and C++ - so qint64 doesn't work as expected.

In Windows there are still some issues, though. See bug #6573

  • I tried using qint64, but it still don't work.
    – user8790
    Commented Jul 16, 2012 at 10:38
  • Thank you. I got it to work with the old style. But with the new style, I still get a error message. I might have done something wrong. It is not important to me since the old style works, but I thought you might want to know. self.iface.activeLayer().geometryChanged.connect(self.geomChanged) gave this error: TypeError: connect() failed between geometryChanged(QgsFeatureId,QgsGeometry) and unislot()
    – user8790
    Commented Jul 17, 2012 at 8:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.