Questions tagged [qgslayertree]
The qgslayertree tag has no usage guidance.
6
questions
1
vote
1
answer
71
views
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()....
0
votes
1
answer
38
views
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 ...
3
votes
1
answer
195
views
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(...
2
votes
2
answers
147
views
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.
5
votes
1
answer
350
views
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....
5
votes
1
answer
143
views
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 = ...