Class: QgsLayerTree¶
- class qgis.core.QgsLayerTree¶
Bases:
QgsLayerTreeGroup
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.
QgsLayerTree() Create a new empty layer tree
Methods
Clear any information from this layer tree.
- rtype
QgsLayerTree
The order in which layers will be rendered on the canvas.
Determines if the layer order should be derived from the layer tree or if a custom override order shall be used instead.
Low-level insertion of children to the node.
Check whether the node is a valid group node
Check whether the node is a valid layer node
The order in which layers will be rendered on the canvas.
Read common XML elements.
Load the layer order from an XML element.
Load the layer tree from an XML element.
Low-level removal of children from the node.
The order in which layers will be rendered on the canvas.
The order in which layers will be rendered on the canvas.
Determines if the layer order should be derived from the layer tree or if a custom override order shall be used instead.
Set check state of children - if mutually exclusive
Write common XML elements.
- param parentElement
Signals
Emitted when the custom layer order has changed.
Emitted when the hasCustomLayerOrder flag changes.
Emitted when the layer order has changed.
- childEvent(self, QChildEvent)¶
- clear(self)¶
Clear any information from this layer tree.
New in version 3.0.
- clone(self) QgsLayerTree ¶
- Return type
- connectNotify(self, QMetaMethod)¶
- customEvent(self, QEvent)¶
- 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 usinglayerOrder()
.See also
See also
See also
New in version 3.0.
- Return type
List[QgsMapLayer]
- customLayerOrderChanged¶
Emitted when the custom layer order has changed.
New in version 3.0: [signal]
- disconnectNotify(self, QMetaMethod)¶
- 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.
See also
New in version 3.0.
- Return type
bool
- hasCustomLayerOrderChanged¶
Emitted when the hasCustomLayerOrder flag changes.
See also
New in version 3.0: [signal]
- Parameters
hasCustomLayerOrder (bool) –
- insertChildrenPrivate(self, index: int, nodes: Iterable[QgsLayerTreeNode])¶
Low-level insertion of children to the node. The children must not have any parent yet!
- isGroup(node: QgsLayerTreeNode) bool ¶
Check whether the node is a valid group node
New in version 2.4.
- Parameters
node (QgsLayerTreeNode) –
- Return type
bool
- isLayer(node: QgsLayerTreeNode) bool ¶
Check whether the node is a valid layer node
New in version 2.4.
- Parameters
node (QgsLayerTreeNode) –
- Return type
bool
- isSignalConnected(self, QMetaMethod) bool ¶
- 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.
See also
New in version 3.0.
- Return type
List[QgsMapLayer]
- layerOrderChanged¶
Emitted when the layer order has changed.
New in version 3.0: [signal]
- nodeVisibilityChanged(self, node: QgsLayerTreeNode)¶
- readCommonXml(self, element: QDomElement)¶
Read common XML elements.
- 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.
- Parameters
doc (QDomElement) –
- 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.
- Parameters
element (QDomElement) –
context (QgsReadWriteContext) –
- Return type
- receivers(self, PYQT_SIGNAL) int ¶
- removeChildrenPrivate(self, from_: int, count: int, destroy: bool = True)¶
Low-level removal of children from the node.
- sender(self) QObject ¶
- senderSignalIndex(self) int ¶
- 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 usinglayerOrder()
.See also
See also
See also
New in version 3.0.
- Parameters
customLayerOrder (Iterable[QgsMapLayer]) –
- 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 usinglayerOrder()
.See also
See also
See also
New in version 3.0.
- Parameters
customLayerOrder (Iterable[str]) –
- 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.
See also
New in version 3.0.
- Parameters
hasCustomLayerOrder (bool) –
- timerEvent(self, QTimerEvent)¶
- updateChildVisibilityMutuallyExclusive(self)¶
Set check state of children - if mutually exclusive
- writeCommonXml(self, element: QDomElement)¶
Write common XML elements.
- writeXml(self, parentElement: QDomElement, context: QgsReadWriteContext)¶
- Parameters
parentElement (QDomElement) –
context (QgsReadWriteContext) –