Subgroup: Layer

Class: QgsLayerTree

class qgis.core.QgsLayerTree

Bases: qgis._core.QgsLayerTreeGroup

Create a new empty layer tree

Namespace with helper functions for layer tree operations.

Only generally useful routines should be here. Miscellaneous utility functions for work with the layer tree are in QgsLayerTreeUtils class.

New in version 3.0: Methods

childEvent
clear Clear any information from this layer tree.
clone
connectNotify
customEvent
customLayerOrder The order in which layers will be rendered on the canvas.
disconnectNotify
hasCustomLayerOrder Determines if the layer order should be derived from the layer tree or if a custom override order shall be used instead.
insertChildrenPrivate
isGroup Check whether the node is a valid group node
isLayer Check whether the node is a valid layer node
isSignalConnected
layerOrder The order in which layers will be rendered on the canvas.
nodeVisibilityChanged
readCommonXml
readLayerOrderFromXml Load the layer order from an XML element.
readXml Load the layer tree from an XML element.
receivers
removeChildrenPrivate
sender
senderSignalIndex
setCustomLayerOrder The order in which layers will be rendered on the canvas.
setCustomLayerOrderByIds The order in which layers will be rendered on the canvas.
setHasCustomLayerOrder Determines if the layer order should be derived from the layer tree or if a custom override order shall be used instead.
timerEvent
updateChildVisibilityMutuallyExclusive
writeCommonXml
writeXml

Signals

customLayerOrderChanged Emitted when the custom layer order has changed.
hasCustomLayerOrderChanged Emitted when the hasCustomLayerOrder flag changes.
layerOrderChanged Emitted when the layer order has changed.

Attributes

childEvent()
clear(self)

Clear any information from this layer tree.

New in version 3.0.

clone(self) → QgsLayerTree
connectNotify()
customEvent()
customLayerOrder(self) → List[QgsMapLayer]

The order in which layers will be rendered on the canvas. Will only be used if the property hasCustomLayerOrder is true. If you need the current layer order that is active, prefer using layerOrder().

See also

layerOrder()

New in version 3.0.

customLayerOrderChanged

Emitted when the custom layer order has changed.

New in version 3.0: [signal]

disconnectNotify()
hasCustomLayerOrder(self) → bool

Determines if the layer order should be derived from the layer tree or if a custom override order shall be used instead.

New in version 3.0.

hasCustomLayerOrderChanged

Emitted when the hasCustomLayerOrder flag changes.

New in version 3.0: [signal]

insertChildrenPrivate()
isGroup(node: QgsLayerTreeNode) → bool

Check whether the node is a valid group node

New in version 2.4.

isLayer(node: QgsLayerTreeNode) → bool

Check whether the node is a valid layer node

New in version 2.4.

isSignalConnected()
layerOrder(self) → List[QgsMapLayer]

The order in which layers will be rendered on the canvas. Depending on hasCustomLayerOrder, this will return either the override customLayerOrder or the layer order derived from the tree. This property is read only.

New in version 3.0.

layerOrderChanged

Emitted when the layer order has changed.

New in version 3.0: [signal]

nodeVisibilityChanged()
readCommonXml()
readLayerOrderFromXml(self, doc: QDomElement)

Load the layer order from an XML element. Make sure that this is only called after the layers are loaded.

New in version 3.0.

readXml(element: QDomElement, context: QgsReadWriteContext) → QgsLayerTree

Load the layer tree from an XML element. It is not required that layers are loaded at this point. resolveReferences() needs to be called after loading the layers and before using the tree.

New in version 3.0.

receivers()
removeChildrenPrivate()
sender()
senderSignalIndex()
setCustomLayerOrder(self, customLayerOrder: Iterable[QgsMapLayer])

The order in which layers will be rendered on the canvas. Will only be used if the property hasCustomLayerOrder is true. If you need the current layer order that is active, prefer using layerOrder().

See also

layerOrder()

New in version 3.0.

setCustomLayerOrderByIds(self, customLayerOrder: Iterable[str])

The order in which layers will be rendered on the canvas. Will only be used if the property hasCustomLayerOrder is true. If you need the current layer order that is active, prefer using layerOrder().

See also

layerOrder()

New in version 3.0.

setHasCustomLayerOrder(self, hasCustomLayerOrder: bool)

Determines if the layer order should be derived from the layer tree or if a custom override order shall be used instead.

New in version 3.0.

timerEvent()
updateChildVisibilityMutuallyExclusive()
writeCommonXml()
writeXml(self, parentElement: QDomElement, context: QgsReadWriteContext)