I have a project which has dozens of groups and subgroups. E.g.:
Main_Group > Sub_Group_1 > Sub_Group_1A > Layer_1A
> Layer_2A
How can I access those layers which are contained within Sub_Group_1A?
I currently have this:
root = QgsProject.instance().layerTreeRoot()
for child in root.children():
if isinstance(child, QgsLayerTreeGroup):
if child.name() == "Main_Group":
for subChild in child.children():
if isinstance(subChild, QgsLayerTreeGroup):
if subChild.name() == 'Sub_Group_1':
# What next?
I have read through the following sources and can get layers in Sub_Group_1 but not in Sub_Group_1A:
Sub_Group_1A. If you can post an answer showing a more cleaner piece of code than what I posted, I will happily accept it :) – Joseph Apr 21 '16 at 15:07