<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 05/16/2013 01:35 AM, Alexia Mondot
      wrote:<br>
    </div>
    <blockquote cite="mid:51949A5D.9060704@c-s.fr" type="cite">
      <meta content="text/html; charset=ISO-8859-1"
        http-equiv="Content-Type">
      <div class="moz-cite-prefix">On 05/15/2013 06:41 PM, David J.
        Bakeman wrote:<br>
      </div>
      <blockquote cite="mid:5193BACD.9060006@comcast.net" type="cite">
        <pre wrap="">On 05/15/2013 02:41 AM, Alexia Mondot wrote:
</pre>
        <blockquote type="cite">
          <pre wrap="">I work on qgis 1.9 and in the API, there is :

</pre>
          <blockquote type="cite">
            <pre wrap="">virtual int addGroup
<a moz-do-not-send="true" class="moz-txt-link-rfc2396E" href="http://www.qgis.org/api/classQgsLegendInterface.html#a25a8cf67b140383bab0c75e90a3eb3f8"><http://www.qgis.org/api/classQgsLegendInterface.html#a25a8cf67b140383bab0c75e90a3eb3f8></a>
(QString name, bool expand=true, QTreeWidgetItem *parent=0)=0
</pre>
          </blockquote>
          <pre wrap="">I've run this function in Python, and it works for me.

You can try :
</pre>
          <blockquote type="cite">
            <pre wrap="">li = qgis.utils.iface.legendInterface()
g1 = li.addGroup("g1")
g2 = li.addGroup("g2",True, g2)
</pre>
          </blockquote>
        </blockquote>
        <pre wrap="">I never attempted that since addGroup() returns an index at least
according to the documentation not a pointer.  In fact if you do the
following (qgis 1.8) it gets listed in group g1 not g2

g3 = li.addGroup("g3", True, g2)</pre>
      </blockquote>
      Sorry, of course, you have to put as the third argument the index
      of the parent group.<br>
      <blockquote type="cite">
        <pre wrap="">li = qgis.utils.iface.legendInterface()
g1 = li.addGroup("g1")
g2 = li.addGroup("g2",True, g<b>1</b>)</pre>
      </blockquote>
      Does this code work for you ?<br>
    </blockquote>
    Yes it does but if I follow it with the<br>
    <br>
    g3 = li.addGroup("g3", True, g2)<br>
    <br>
    g3 ends up in group g1 NOT g2 as I expected in 1.8 in 1.9 it works
    so it's been fixed!<br>
     <br>
    <blockquote cite="mid:51949A5D.9060704@c-s.fr" type="cite"> <br>
      <blockquote cite="mid:5193BACD.9060006@comcast.net" type="cite">
        <blockquote type="cite">
          <pre wrap="">On 05/15/2013 09:25 AM, David J. Bakeman wrote:
</pre>
          <blockquote type="cite">
            <pre wrap="">On 05/14/2013 03:02 PM, David J. Bakeman wrote:
</pre>
            <blockquote type="cite">
              <pre wrap="">On 05/14/2013 02:56 PM, Etienne Tourigny wrote:
</pre>
              <blockquote type="cite">
                <pre wrap="">On Tue, May 14, 2013 at 6:21 PM, David J. Bakeman
<<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:dbakeman@comcast.net">dbakeman@comcast.net</a> <a moz-do-not-send="true" class="moz-txt-link-rfc2396E" href="mailto:dbakeman@comcast.net"><mailto:dbakeman@comcast.net></a>> wrote:

    Is it possible to create a group within a group in python?

    li = qgis.utils.iface.legendInterface()
    g1 = li.addGroup("g1")
    g2 = li.addGroup("g2",g2)


did you try this? 

g2 = li.addGroup("g2", g1)
</pre>
              </blockquote>
              <pre wrap="">Sorry for the typo yes that is exactly what I tried.  Does it work for
you?
</pre>
            </blockquote>
            <pre wrap="">I built master from source and it doesn't work there either.

P.S. I think this response is in plain text so shouldn't get rejected.
</pre>
            <blockquote type="cite">
              <blockquote type="cite">
                <pre wrap="">    The above seems like it should work but it doesn't.

    Thanks.

    _______________________________________________
    Qgis-user mailing list
    <a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:Qgis-user@lists.osgeo.org">Qgis-user@lists.osgeo.org</a> <a moz-do-not-send="true" class="moz-txt-link-rfc2396E" href="mailto:Qgis-user@lists.osgeo.org"><mailto:Qgis-user@lists.osgeo.org></a>
    <a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/qgis-user">http://lists.osgeo.org/mailman/listinfo/qgis-user</a>


</pre>
              </blockquote>
              <pre wrap="">_______________________________________________
Qgis-user mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:Qgis-user@lists.osgeo.org">Qgis-user@lists.osgeo.org</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/qgis-user">http://lists.osgeo.org/mailman/listinfo/qgis-user</a>
</pre>
            </blockquote>
            <pre wrap="">_______________________________________________
Qgis-user mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:Qgis-user@lists.osgeo.org">Qgis-user@lists.osgeo.org</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/qgis-user">http://lists.osgeo.org/mailman/listinfo/qgis-user</a>


</pre>
          </blockquote>
          <pre wrap="">

_______________________________________________
Qgis-user mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:Qgis-user@lists.osgeo.org">Qgis-user@lists.osgeo.org</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/qgis-user">http://lists.osgeo.org/mailman/listinfo/qgis-user</a>
</pre>
        </blockquote>
        <pre wrap="">
</pre>
      </blockquote>
      <br>
    </blockquote>
    <br>
  </body>
</html>