<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi Guillaume, <br>
<br>
<div class="moz-cite-prefix">On 26. 02. 14 10:15, Guillaume GIMENO
wrote:<br>
</div>
<blockquote
cite="mid:CAHL0Nf897YHgFONpPK-f3-S4wen7sQF=j4BpnzozjDoOiVZsew@mail.gmail.com"
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 class="gmail_default" style="display:inline"> </div>
when the
<div class="gmail_default"
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 moz-do-not-send="true"
href="http://qgis.org/api/classQgsVectorLayer.html#a403f235d3743aa59bb3aad69a72a5705"
target="_blank">http://qgis.org/api/classQgsVectorLayer.html#a403f235d3743aa59bb3aad69a72a5705</a><br>
)
<div class="gmail_default" style="display:inline">
.</div>
<br>
</font></div>
<div><font face="georgia, serif"><br>
I have
<div class="gmail_default" style="display:inline">tried two</div>
method
<div class="gmail_default" 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 class="gmail_default"><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>
I can't tell why, but you should use the second method as it is the
new signal/slot connection style.
<blockquote
cite="mid:CAHL0Nf897YHgFONpPK-f3-S4wen7sQF=j4BpnzozjDoOiVZsew@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>
<div>
</div>
<div><font face="georgia, serif"><br>
</font></div>
<div>
<div class="gmail_default"><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>
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().
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
mapLayers() if you want all the layers<br>
<br>
Cheers,<br>
<br>
Denis<br>
<br>
<br>
[0]
<a class="moz-txt-link-freetext" href="http://qgis.org/api/classQgisInterface.html#a231f32fbf95004aebb067cb98f3a391c">http://qgis.org/api/classQgisInterface.html#a231f32fbf95004aebb067cb98f3a391c</a><br>
<br>
</body>
</html>