PyQGIS: feature added signal throws an error message
We are searching data for your request:
Upon completion, a link will appear to access the found materials.
For my PyQGIS plugin 2.2, I try to:
def logFeatureAdded(self,layerId,addfeatures): message = str(layerId) + " has features added: " for feature in addedFeatures: message += str( feature.id() ) + ", " QgsMessageLog.logMessage(message) QApplication.beep() layer.featureAdded.connect(self.logFeatureAdded)
When I try to add a feature, this following error message appears:
TypeError : logFeaturesAdded() takes exactly 3 arguments (2 given).
How can I use the
As you can see in the QGIS API docs, the
featureAddedsignal only passes one argument, namely, the feature ID.
When you create your slot, you must use a single argument (besides
self), this way:
def logFeatureAdded(self, fid): message = str( fid ) QgsMessageLog.logMessage(message) QApplication.beep()
This should solve your problem!