[Qgis-developer] Python: groups in QgsLegendInterface()

Chris Crook ccrook at linz.govt.nz
Thu Jun 9 22:05:03 EDT 2011


Hi All

How can I determine the group index of a group containing a layer?

Basically I'm creating a new layer, and wanting to add it to the same group as a new layer. It looks like the only way to add a layer to a group is via the group index.  But I can't see any way to determine the group index of an existing layer.  

The nearest I've got is 

  [i for i,x in enumerate(legend.groupLayerRelationship()) if layer.id() in x[1]]

But this doesn't work with nested groups.

Any other suggestions?

Thanks
Chris
______________________________________________________________________________________________________

This message contains information, which is confidential and may be subject to legal privilege. 
If you are not the intended recipient, you must not peruse, use, disseminate, distribute or copy this message.
If you have received this message in error, please notify us immediately (Phone 0800 665 463 or info at linz.govt.nz) and destroy the original message.
LINZ accepts no responsibility for changes to this email, or for any attachments, after its transmission from LINZ.

Thank you.
______________________________________________________________________________________________________


More information about the Qgis-developer mailing list