Questions tagged [qgslayertree]
The qgslayertree tag has no usage guidance.
Adding group items to Layout legend using PyQGIS
I want to add to the Print Layout Legend groups, subgroups, and layers using PyQGIS like in the picture: But I can only add layers: root = QgsLayerTree() layers_ = self.qgis_project.mapLayers()....
QGIS crashes after removeChildNode() Called
I have followed QGIS examples on how to move layers on TOC by inserting and removing nodes. I tried the QGIS documentation approach, which clones a node then reinserts it and removes the first one as ...
Loading QLR file in QGIS using PyQGIS
I'm trying to load a qlr-file in QGIS 3.16 and zoom to a certain area using python: QgsLayerDefinition.loadLayerDefinition('E:/QGIS/test.qlr',QgsProject.instance(), QgsProject.instance().layerTreeRoot(...
Selected item in layertree group or layer?
How do I check in PyQgis if the selected item in de QgsLayerTree is a group or a layer. I really can't find the answer.
Getting vector layer from layers within group using PyQGIS
It's not difficult to get a list of layers within a group in the Layers panel of a QGIS 3.x project: root = QgsProject.instance().layerTreeRoot() groupName = "GROUP_name" group = root....
Preserving QgsLayerTreeViewIndicator on moving node in layer tree with PyQGIS
I am using the script below to display an icon next to my layer in the layer tree view, which works fine. However, when a user moves the position of that node, the indicator disappears. layer1 = ...