2

Regarding my pyqgis plugin 2.2 , I've implemented signal on a vector layer event successfully. For instance, whenever i create a new feature, i can read a new basic message appeared via QGIS logging system : " feature added".

But for some events, besides this basic message, i would like read the name of the layer and/or , the id of the feature/ the attribut name / the geometry type (line,surf,punct).

How to bring more info details for the events?

I paste below my piece of code :

def logLayerModified(self, onlyGeometry = None ): 
    QgsMessageLog.logMessage( "layer modified" ) 
    QApplication.beep() 

def logAttributeAdded(self,QgsFeatureId): 
    QgsMessageLog.logMessage( "attribut added" ) 
    QApplication.beep() 

def logAttributeDeleted(self,QgsFeatureId): 
    QgsMessageLog.logMessage( "attribut deleted" ) 
    QApplication.beep() 

def logFeatureAdded(self,QgsFeatureId): 
    QgsMessageLog.logMessage("feature added, id = " + str(QgsFeatureId)) 
    QApplication.beep() 

def logFeatureDeleted(self,QgsFeatureId): 
    QgsMessageLog.logMessage("feature deleted, id = " + str(QgsFeatureId)) 
    QApplication.beep() 

def logGeometryChanged(self,fid):
    QgsMessageLog.logMessage("Geometry changed, id = " + str(fid)) 
    QApplication.beep() 

def logAttributeValueChanged(self, QgsFeatureId fid, int idx, const QVariant &):
    QgsMessageLog.logMessage("Attribut value changed", id = " + str(QgsFeatureId)) 
    QApplication.beep() 

def logBeforeLayerCommitChange(self): 
    QgsMessageLog.logMessage( "commit change" ) 
    QApplication.beep() 

layer.layerModified.connect(self.logLayerModified)
layer.attributeAdded.connect(self.logAttributeAdded)
layer.attributeDeleted.connect(self.logAttributeDeleted)
layer.featureAdded.connect(self.logFeatureAdded)
layer.featureDeleted.connect(self.logFeatureDeleted)
layer.featureDeleted.connect(self.logGeometryChanged)
layer.beforeCommitChanges.connect(self.logBeforeLayerCommitChange)
layer.AttributeValueChanged.connect(self.logAttributeValueChanged)
  • 1
    Are you still interested in this? I could help you. – Germán Carrillo Jan 28 '15 at 18:06
  • 2
    @gcarrillo - You should still post an answer if you're able to as it could help others with a similar problem :) – Joseph Jul 31 '15 at 12:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.