Hi all<br><br>I managed to reconstruct my legend in my QTreeWidget by using a dictionary to store the item I have already added in the tree while looping through groupLayerRelationship !<br><br>Cheers<br>Kimaidou<br><br><div class="gmail_quote">
2011/6/20 kimaidou <span dir="ltr">&lt;<a href="mailto:kimaidou@gmail.com">kimaidou@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi devs,<br>
<br>I am a bit stuck here....<br>I would like to recreate the complete legend tree inside a python plugin. I have chosen to use a QtreeWidget to do so.<br><br>Imagine I have:<br>*****************<br>group 0 (empty)<br>
<br>group 1<br>|-- group 11<br>
   |-- layer 11a<br>   |-- layer 11b<br>|-- layer 1a<br><br>layer a<br><br>group 2<br>|-- group 21<br>|-- layer 2a<br>***********************<br><br>I have seen the <br>

<p style="margin:0px;text-indent:0px">iface.legendInterface().groupLayerRelationship()</p><p style="margin:0px;text-indent:0px">returns usefull information, but in a flat &quot;C-style&quot; way like :</p><p style="margin:0px;text-indent:0px">

<br></p>[<br>  [&#39;group 0&#39;, [] ], <br>  [&#39;group 1&#39;, [&#39;group 11&#39;, &#39;layer_1a_10020100526085601790&#39;] ], <br>  [&#39;&#39;, [&#39;layer_a_20110617181245226&#39;] ], <br>  [&#39;group 2&#39;, [&#39;groupe21&#39;, &#39;layer_2a_20110616121558434&#39;] ], <br>

  [&#39;group 11&#39;, [&#39;layer_11a_20100526085601799&#39;, &#39;layer_11b_gen20100526100356932&#39;] ], <br>  [&#39;groupe21&#39;, []]<br>]<br><br><br>I would like to loop though this result and create my own hierarchical representation such as :<br>

[<br>    &#39;name&#39; : &#39;group 0&#39; , &#39;type&#39; : &#39;group&#39;, &#39;children&#39; : [],<br>     &#39;name&#39; : &#39;group 1&#39; , &#39;type&#39; : &#39;group&#39;, &#39;children&#39; : [<br>        &#39;name&#39; : &#39;group 11&#39; , &#39;type&#39; : &#39;group&#39;, &#39;children&#39; : [<br>

            &#39;name&#39; : &#39;layer 11a&#39; , &#39;type&#39; : &#39;layer&#39;, &#39;children&#39; : [],<br>            &#39;name&#39; : &#39;layer 11b&#39; , &#39;type&#39; : &#39;layer&#39;, &#39;children&#39; : []<br>

        ],<br>        &#39;name&#39; : &#39;layer 1a&#39; , &#39;type&#39; : &#39;layer&#39;, &#39;children&#39; : []<br>    ],<br>    &#39;name&#39; : &#39;layer a&#39; , &#39;type&#39; : &#39;layer&#39;, &#39;children&#39; : [],<br>

    &#39;name&#39; : &#39;group 2&#39; , &#39;type&#39; : &#39;group&#39;, &#39;children&#39; : [<br>        &#39;name&#39; : &#39;group 21&#39; , &#39;type&#39; : &#39;group&#39;, &#39;children&#39; : [],<br>        &#39;name&#39; : &#39;layer 2a&#39; , &#39;type&#39; : &#39;layer&#39;, &#39;children&#39; : []<br>

    ]<br>]<br><br>I have tried hard since yesterday, but have not succeeded... Has anyone already encoutered this need ? <br><br>Thanks in advance, <br><font color="#888888">kimaidou<br>
</font></blockquote></div><br>