Hi David,
It's finally working! Thank you (and sorry for the delay in getting back to
you).
AF
David Signer wrote:
First you have to retrieve the current layertree to do modifications:
tree = QgsProject.instance().layerTreeRoot()
...and after setting your order:
tree.setCustomLayerOrder(layersII)
First you have to retrieve the current layertree to do modifications:
tree = QgsProject.instance().layerTreeRoot()
...and after setting your order:
tree.setCustomLayerOrder(layersII)
...you have to set that a layer order should be considered:
tree.setHasCustomLayerOrder(True)
On Wed, Oct 23, 2024
order.insert(0, order.pop(order.index(layer)))
root.setCustomLayerOrder(order)
layer.triggerRepaint()
root.setHasCustomLayerOrder(False)
From: QGIS-Developer On Behalf Of
coder via QGIS-Developer
Sent: Wednesday, October 23, 2024 11:05 AM
To: qgis-developer@lists.osgeo.org
Su
Hello
I'm trying to change the rendering order for the layers in the canvas with
the aid of QgsLayerTree. The code grabs each layer, checks whether is a
QgsMapLayer instance, and generates a reordered list (layersII). Then, the
code executes:
QgsLayerTree().setCustomLayerOrder(layersII)
but nothin