[Qgis-developer] Moving a layer with PyQGIS using the new layer tree

Martin Dobias wonder.sk at gmail.com
Sun Dec 21 05:55:08 PST 2014


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20141221/7d77ba29/attachment.html>


More information about the Qgis-developer mailing list