<div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">Thanks, it works on Debian ; But on Windows 7 and os x mavericks I have an error :</div><div class="gmail_extra"><blockquote type="cite"><div dir="ltr">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><font face="georgia, serif">AttributeError: 'QgsVectorLayer' object has no attribute 'rendererChanged<div class="gmail_default" style="font-family:georgia,serif;display:inline">
'</div></font></blockquote><div> <br></div></div></blockquote><br><div class="gmail_quote">2014-02-26 10:46 GMT+01:00 Denis Rouzaud <span dir="ltr"><<a href="mailto:denis.rouzaud@gmail.com" target="_blank">denis.rouzaud@gmail.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
Hi Guillaume, <br><div class="">
<br>
<div>On 26. 02. 14 10:15, Guillaume GIMENO
wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr"><font face="georgia, serif">Hi,</font>
<div><font face="georgia, serif"><br>
I am working on a plugin and want to get a signal
<div style="display:inline"> </div>
when the
<div style="font-family:georgia,serif;display:inline">
symbology</div>
of a vector layer is changed by the user. In the doc, there
is a signal that seems to fit (<br>
<a href="http://qgis.org/api/classQgsVectorLayer.html#a403f235d3743aa59bb3aad69a72a5705" target="_blank">http://qgis.org/api/classQgsVectorLayer.html#a403f235d3743aa59bb3aad69a72a5705</a><br>
)
<div style="display:inline">
.</div>
<br>
</font></div>
<div><font face="georgia, serif"><br>
I have
<div style="display:inline">tried two</div>
method
<div style="display:inline">s</div>
called : </font>
<div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><font face="georgia, serif">QObject.connect(self.iface.activeLayer(),
SIGNAL("rendererChanged()"), self.DoSomething)</font></blockquote>
<font face="georgia, serif"><br>
I have also tried : </font></div>
<div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><font face="georgia, serif">
self.iface.activeLayer().rendererChanged.connect(self.DoSomething)</font></blockquote>
<font face="georgia, serif"><br>
</font>
<div><font face="georgia, serif">On os
x mavericks nothing happens with the first method and
for the second I have a error :</font></div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><font face="georgia, serif">AttributeError: 'QgsVectorLayer'
object has no attribute 'rendererChanged'</font></blockquote>
</div>
</div>
</div>
</blockquote>
<br></div>
I can't tell why, but you should use the second method as it is the
new signal/slot connection style.
<div class=""><blockquote type="cite">
<div dir="ltr">
<div>
<div>
</div>
<div><font face="georgia, serif"><br>
</font></div>
<div>
<div><font face="georgia, serif">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.</font></div>
</div>
</div>
</div>
</blockquote>
<br></div>
This is because iface.activeLayer() is the currently selected layer
in the legend. [0]<br>
If you want to do so, you might want to connect all layers by
browsing them using:<br>
iface.mapCanvas().layers() if you want all the displayed layers
actually displayed in the map<br>
or <br>
QgsMapLayerRegistry.instance().
mapLayers() if you want all the layers<br>
<br>
Cheers,<br>
<br>
Denis<br>
<br>
<br>
[0]
<a href="http://qgis.org/api/classQgisInterface.html#a231f32fbf95004aebb067cb98f3a391c" target="_blank">http://qgis.org/api/classQgisInterface.html#a231f32fbf95004aebb067cb98f3a391c</a><br>
<br>
</div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>This mail was sent using 100% recycled electrons.
</div></div>