[Qgis-developer] Get a signal when the symbology changed
Guillaume GIMENO
gimeno.g at gmail.com
Wed Feb 26 05:25:18 PST 2014
Thanks, it works on Debian ; But on Windows 7 and os x mavericks I have an
error :
AttributeError: 'QgsVectorLayer' object has no attribute 'rendererChanged
> '
>
2014-02-26 10:46 GMT+01:00 Denis Rouzaud <denis.rouzaud at gmail.com>:
> 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
>
>
--
This mail was sent using 100% recycled electrons.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20140226/abf2a675/attachment.html>
More information about the Qgis-developer
mailing list