Subgroup: Layer

Class: QgsLayerTreeLayer

class qgis.core.QgsLayerTreeLayer

Bases: qgis._core.QgsLayerTreeNode

Layer tree node points to a map layer.

The node can exist also without a valid instance of a layer (just ID). That means the referenced layer does not need to be loaded in order to use it in layer tree. In such case, resolveReferences() method can be called once the layer is loaded.

A map layer is supposed to be present in one layer tree just once. It is however possible that temporarily a layer exists in one tree more than just once, e.g. while reordering items with drag and drop.

New in version 2.4: Methods

attachToLayer
blockSignals
checkedLayers Returns a list of any checked layers which belong to this node or its children.
childEvent
children Get list of children of the node.
clone
connectNotify
customEvent
customProperties Return list of keys stored in custom properties
customProperty Read a custom property from layer.
deleteLater
disconnect
disconnectNotify
dump
dumpObjectInfo
dumpObjectTree
dynamicPropertyNames
event
eventFilter
findChild findChild(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> QObject
findChildren findChildren(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject]
inherits
insertChildrenPrivate
installEventFilter
isExpanded Return whether the node should be shown as expanded or collapsed in GUI
isItemVisibilityCheckedRecursive Return whether this node is checked and all its children.
isItemVisibilityUncheckedRecursive Return whether this node is unchecked and all its children.
isSignalConnected
isVisible Returns whether a node is really visible (ie checked and all its ancestors checked as well)
isWidgetType
isWindowType
itemVisibilityChecked Returns whether a node is checked (independently of its ancestors or children)
killTimer
layer
layerId
metaObject
moveToThread
name Returns the layer’s name.
nodeType Find out about type of the node.
objectName
parent Get pointer to the parent.
property
pyqtConfigure Each keyword argument is either the name of a Qt property or a Qt signal.
readCommonXml
readXml Read layer node from XML.
receivers
removeChildrenPrivate
removeCustomProperty Remove a custom property from layer.
removeEventFilter
resolveReferences Resolves reference to layer from stored layer ID (if it has not been resolved already)
sender
senderSignalIndex
setCustomProperty Set a custom property for the node.
setExpanded Set whether the node should be shown as expanded or collapsed in GUI
setItemVisibilityChecked Check or uncheck a node (independently of its ancestors or children)
setItemVisibilityCheckedParentRecursive Check or uncheck a node and all its parents
setItemVisibilityCheckedRecursive Check or uncheck a node and all its children (taking into account exclusion rules)
setName Sets the layer’s name.
setObjectName
setParent
setProperty
signalsBlocked
startTimer
takeChild Remove a child from a node
thread
timerEvent
tr
writeCommonXml
writeXml

Attributes

NodeGroup
NodeLayer
addedChildren Emitted when one or more nodes have been added to a node within the tree [signal]
customPropertyChanged Emitted when a custom property of a node within the tree has been changed or removed [signal]
destroyed destroyed(self, QObject = None) [signal]
expandedChanged Emitted when the collapsed/expanded state of a node within the tree has been changed [signal]
layerLoaded Emitted when a previously unavailable layer got loaded.
layerWillBeUnloaded Emitted when a previously available layer got unloaded (from layer registry).
nameChanged Emitted when the name of the node is changed
objectNameChanged objectNameChanged(self, str) [signal]
removedChildren Emitted when one or more nodes has been removed from a node within the tree [signal]
staticMetaObject
visibilityChanged Emitted when check state of a node within the tree has been changed [signal]
willAddChildren Emitted when one or more nodes will be added to a node within the tree [signal]
willRemoveChildren Emitted when one or more nodes will be removed from a node within the tree [signal]
attachToLayer(self)
childEvent()
clone(self) → QgsLayerTreeLayer
connectNotify()
customEvent()
disconnectNotify()
dump(self) → str
insertChildrenPrivate()
isSignalConnected()
layer(self) → QgsMapLayer
layerId(self) → str
layerLoaded

Emitted when a previously unavailable layer got loaded. [signal]

layerWillBeUnloaded

Emitted when a previously available layer got unloaded (from layer registry).

New in version 2.6: [signal]

name(self) → str

Returns the layer’s name.

New in version 3.0.

readCommonXml()
readXml(element: QDomElement, context: QgsReadWriteContext) → QgsLayerTreeLayer

Read layer node from XML. Returns new instance. Does not resolve textual references to layers. Call resolveReferences() afterwards to do it.

readXml(element: QDomElement, project: QgsProject, context: QgsReadWriteContext) -> QgsLayerTreeLayer Read layer node from XML. Returns new instance. Also resolves textual references to layers from the project (calls resolveReferences() internally).

New in version 3.0.

receivers()
removeChildrenPrivate()
resolveReferences(self, project: QgsProject, looseMatching: bool = False)

Resolves reference to layer from stored layer ID (if it has not been resolved already)

New in version 3.0.

sender()
senderSignalIndex()
setName(self, n: str)

Sets the layer’s name.

New in version 3.0.

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