[Qgis-user] Nested group in python

Alexia Mondot alexia.mondot at c-s.fr
Thu May 16 01:35:41 PDT 2013


On 05/15/2013 06:41 PM, David J. Bakeman wrote:
> On 05/15/2013 02:41 AM, Alexia Mondot wrote:
>> I work on qgis 1.9 and in the API, there is :
>>
>>> virtual int addGroup
>>> <http://www.qgis.org/api/classQgsLegendInterface.html#a25a8cf67b140383bab0c75e90a3eb3f8>
>>> (QString name, bool expand=true, QTreeWidgetItem *parent=0)=0
>> I've run this function in Python, and it works for me.
>>
>> You can try :
>>> li = qgis.utils.iface.legendInterface()
>>> g1 = li.addGroup("g1")
>>> g2 = li.addGroup("g2",True, g2)
> 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)
Sorry, of course, you have to put as the third argument the index of the 
parent group.
> li = qgis.utils.iface.legendInterface()
> g1 = li.addGroup("g1")
> g2 = li.addGroup("g2",True, g*1*)
Does this code work for you ?

>> On 05/15/2013 09:25 AM, David J. Bakeman wrote:
>>> On 05/14/2013 03:02 PM, David J. Bakeman wrote:
>>>> On 05/14/2013 02:56 PM, Etienne Tourigny wrote:
>>>>> On Tue, May 14, 2013 at 6:21 PM, David J. Bakeman
>>>>> <dbakeman at comcast.net <mailto:dbakeman at comcast.net>> 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)
>>>> Sorry for the typo yes that is exactly what I tried.  Does it work for
>>>> you?
>>> 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.
>>>>>      The above seems like it should work but it doesn't.
>>>>>
>>>>>      Thanks.
>>>>>
>>>>>      _______________________________________________
>>>>>      Qgis-user mailing list
>>>>>      Qgis-user at lists.osgeo.org <mailto:Qgis-user at lists.osgeo.org>
>>>>>      http://lists.osgeo.org/mailman/listinfo/qgis-user
>>>>>
>>>>>
>>>> _______________________________________________
>>>> Qgis-user mailing list
>>>> Qgis-user at lists.osgeo.org
>>>> http://lists.osgeo.org/mailman/listinfo/qgis-user
>>> _______________________________________________
>>> Qgis-user mailing list
>>> Qgis-user at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/qgis-user
>>>
>>>
>>
>>
>> _______________________________________________
>> Qgis-user mailing list
>> Qgis-user at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/qgis-user
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20130516/33def395/attachment.html>


More information about the Qgis-user mailing list