[Qgis-developer] PyQgis : Sorting alphabetically groups into legend widget
Martin Dobias
wonder.sk at gmail.com
Thu Jul 9 02:18:00 PDT 2015
Hi Pierre
QgsLayerTreeModel and QgsLayerTreeView are not necessary to use here:
they only make the QgsLayerTreeNode hierarchy available for display in
Qt widgets.
What you actually want to do is to manipulate the tree nodes
(QgsLayerTreeGroup and QgsLayerTreeLayer objects) - for a group you
just need to reorder the children nodes according to the alphabetical
order. See my blog post on manipulating nodes:
http://www.lutraconsulting.co.uk/blog/2014/07/25/qgis-layer-tree-api-part-2/
Regards
Martin
On Mon, Jul 6, 2015 at 6:04 PM, PIERRE Sylvain
<sylvain.pierre at bas-rhin.fr> wrote:
>
>
> Hello,
>
>
>
> In a python script I want to sort by name groups inside legend widget.
>
> I’ve done some test with QgsLayerTreeModel and QgsLayerTreeview but with no
> result
>
> What’s the best (an simple!) way to do that?
>
>
>
> Thanks
>
>
>
> Sylvain
>
>
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
More information about the Qgis-developer
mailing list