I am trying to find the name of subgroups using PyQGIS. I have been trying to use Playing with subgroups
I am however unable to traverse and get the names of the subgroup. I have tried the code on this article.
for child in root.children():
if isinstance(child, QgsLayerTreeGroup):
print "- group: " + child.name()
if child.name() == "test": #to check subgroups within test group
for child in root.children(): #which I think i am making a mistake here because the root is supposed to contain all nodes
for subChild in child.children():and thenprint subChild.name(), since you want to start reading children from your main group (not from root anymore). – Germán Carrillo Sep 07 '15 at 19:20