Hi Guillaume,

On 26. 02. 14 10:15, Guillaume GIMENO wrote:
Hi,

I am working on a plugin and want to get a signal
when the
symbology
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
)
.


I have
tried two
 method
s
called :

    QObject.connect(self.iface.activeLayer(),
    SIGNAL("rendererChanged()"), self.DoSomething)


I have also tried :

    self.iface.activeLayer().rendererChanged.connect(self.DoSomething)


On os x mavericks nothing happens with the first method and for the second I have a error :

    AttributeError: 'QgsVectorLayer' object has no attribute
    'rendererChanged'


I can't tell why, but you should use the second method as it is the new signal/slot connection style.

But on Debian, I can get the signal but just for the layer which is selected when the plugin is run ; On the other layers, if I change the color, nothing happens.

This is because iface.activeLayer() is the currently selected layer in the legend. [0] If you want to do so, you might want to connect all layers by browsing them using: iface.mapCanvas().layers() if you want all the displayed layers actually displayed in the map
or
QgsMapLayerRegistry.instance(). mapLayers() if you want all the layers

Cheers,

Denis


[0] http://qgis.org/api/classQgisInterface.html#a231f32fbf95004aebb067cb98f3a391c

_______________________________________________
Qgis-developer mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to