[Qgis-developer] Moving a layer with PyQGIS using the new layer tree
Germán Carrillo
carrillo.german at gmail.com
Sun Dec 21 08:31:33 PST 2014
Nobody said he wasn't :)
Please also modify the last Python line in the "Removing nodes" section
from [1].
Instead of:
QgsMapLayerRegistry.instance().addMapLayer(layer1)
It should be:
QgsMapLayerRegistry.instance().removeMapLayers([layer1.id()])
Thanks for your work!
Regards,
Germán
---
[1]
http://www.lutraconsulting.co.uk/blog/2014/07/25/qgis-layer-tree-api-part-2/
2014-12-21 8:55 GMT-05:00 Martin Dobias <wonder.sk at gmail.com>:
> Hi
>
> On Thu, Dec 18, 2014 at 9:50 PM, Germán Carrillo <
> carrillo.german at gmail.com> wrote:
>>
>> Thank you Luigi.
>>
>> So, I guess the following code would be enough to make the example given
>> in [1] much more generic:
>>
>> #######
>> cloned_group1 = node_group1.clone()
>> root.insertChildNode(0, cloned_group1)
>>
>> parent = node_group1.parent() # new code
>>
>> parent.removeChildNode(node_group1) # replace root by parent
>> #######
>>
>
> Luigi is right - you need to call removeChildNode() on the parent node.
> When I will find some time I will add a note to the example.
>
> Cheers
> Martin
>
>
--
-----------
|\__
(:>__)(
|/
Soluciones Geoinformáticas Libres
http://geotux.tuxfamily.org/
http://twitter.com/GeoTux2
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20141221/2939e32f/attachment.html>
More information about the Qgis-developer
mailing list