<div dir="ltr">Nobody said he wasn't :)<div><br></div><div>Please also modify the last Python line in the "Removing nodes" section from [1].</div><div><br></div><div>Instead of: </div><div><pre><code>QgsMapLayerRegistry.instance().addMapLayer(layer1)
</code></pre><pre><code>It should be:</code></pre><pre><code><pre><code>QgsMapLayerRegistry.instance().removeMapLayers([<a href="http://layer1.id">layer1.id</a>()])
</code></pre></code></pre></div><div><br></div><div>Thanks for your work!</div><div><br></div><div>Regards, </div><div><br></div><div>Germán </div><div>---</div><div>[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><div class="gmail_extra"><br><div class="gmail_quote">2014-12-21 8:55 GMT-05:00 Martin Dobias <span dir="ltr"><<a href="mailto:wonder.sk@gmail.com" target="_blank">wonder.sk@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi<br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Thu, Dec 18, 2014 at 9:50 PM, Germán Carrillo <span dir="ltr"><<a href="mailto:carrillo.german@gmail.com" target="_blank">carrillo.german@gmail.com</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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></blockquote><div><br></div></span><div> 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.</div><div><br></div><div>Cheers</div><span class="HOEnZb"><font color="#888888"><div>Martin</div><div><br></div></font></span></div></div></div>
</blockquote></div><br><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>