<div dir="ltr">Thank you Luigi. <div><br></div><div>So, I guess the following code would be enough to make the example given in [1] much more generic:</div><div><br></div><div>#######</div><div>cloned_group1 = node_group1.clone()<br></div><div><div>root.insertChildNode(0, cloned_group1)</div><div><br></div><div>parent = node_group1.parent()                   # new code</div><div><br></div><div>parent.removeChildNode(node_group1)     # replace root by parent</div></div><div>#######<br></div><div><br></div><div><br></div><div style>Wouldn't make sense to post such modified example instead?</div><div><div><br></div><div style>Regards, </div><div style><br></div><div style>Germán </div><div class="gmail_extra">---<br></div><div class="gmail_extra">[1] <a href="http://www.lutraconsulting.co.uk/blog/2014/07/25/qgis-layer-tree-api-part-2/">http://www.lutraconsulting.co.uk/blog/2014/07/25/qgis-layer-tree-api-part-2/</a> </div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br><div class="gmail_quote">2014-12-17 17:39 GMT-05:00 Luigi Pirelli <span dir="ltr"><<a href="mailto:luipir@gmail.com" target="_blank">luipir@gmail.com</a>></span>:<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="im"><span style="color:rgb(34,34,34);line-height:22px">You have to refer to the group as root to remove his child</span><div style="color:rgb(34,34,34);line-height:22px"><br></div><div style="color:rgb(34,34,34);line-height:22px">Regards Luigi Pirelli</div><div style="color:rgb(34,34,34);line-height:22px"><br></div>On Wednesday, 17 December 2014, Germán Carrillo <<a href="mailto:carrillo.german@gmail.com" target="_blank">carrillo.german@gmail.com</a>> wrote:<br></span><div class=""><div class="h5"><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Hi all (and Martin D.),<div><br></div><div><br></div><div>I've been trying to reproduce the instructions given here [1] for moving layers. It seems that the code doesn't work if the layer to be moved is inside a group.</div><div><br></div><div>Specifically, trying to move a layer that is inside a group, I can add the clonned layer to the layer tree but I cannot get the original layer removed, i.e., the following command doesn't work:</div><div><br></div><div>   root.removeChildNode( originalLayer )<br></div><div><div><br></div><div>It doesn't throw any message nor change the map/ToC status.</div><div><br></div></div><div><br></div><div>Can you reproduce the problem? I'm using QGIS 2.6.1 on Ubuntu.</div><div><br></div><div><br></div><div>Regards, </div><div><br></div><div>Germán Carrillo<br clear="all"><div>--</div><div>[1] <a href="http://www.lutraconsulting.co.uk/blog/2014/07/25/qgis-layer-tree-api-part-2/" target="_blank">http://www.lutraconsulting.co.uk/blog/2014/07/25/qgis-layer-tree-api-part-2/</a> </div><div><br></div>-- <br><div>-----------<br>   |\__  <br>(:>__)(<br>   |/    <br><br>Soluciones Geoinformáticas Libres                            <br><a href="http://geotux.tuxfamily.org/" target="_blank">http://geotux.tuxfamily.org/</a><br><a href="http://twitter.com/GeoTux2" target="_blank">http://twitter.com/GeoTux2</a><br></div>
</div></div>
</blockquote>
</div></div></blockquote></div><br clear="all"><div><br></div>-- <br><div class="gmail_signature">-----------<br>   |\__  <br>(:>__)(<br>   |/    <br><br>Soluciones Geoinformáticas Libres                            <br><a href="http://geotux.tuxfamily.org/">http://geotux.tuxfamily.org/</a><br><a href="http://twitter.com/GeoTux2">http://twitter.com/GeoTux2</a><br></div>
</div></div></div>