3

I would like to have the signal when the color of a vector layer is changed by the user. In the doc, there is a signal that seems to fit (http://qgis.org/api/classQgsVectorLayer.html#a403f235d3743aa59bb3aad69a72a5705) but nothing happens when it is called.

I have a method called rendererChanged: QObject.connect(self.iface.activeLayer(), SIGNAL("rendererChanged()"), self.DoSomething)

When executed, my function DoSomething is not executed.

I have also tried : self.iface.activeLayer().rendererChanged.connect(self.toto)

But I get this error : AttributeError: 'QgsVectorLayer' object has no attribute 'rendererChanged'

2

You have to use a Canvas-Object as first agrument in QObject.connect(). This snippset works for me:

def _onRenderComplete():
    print("do something")

_canvas = qgis.utils.iface.mapCanvas()
QObject.connect(_canvas, SIGNAL("renderComplete(QPainter *)"), _onRenderComplete)
  • Or the more recent method of connecting signals and slots: iface.mapCanvas().renderComplete.connect(_onRenderComplete) – Joseph Aug 21 '17 at 11:45

Your Answer

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

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