I can select a group layer (for example C) using the following script. But I can only select groups in root level (A or C). I am struggling to select subgroups. I play with the script, but no success.
name = 'C'
view = iface.layerTreeView()
m = view.model()
listIndexes = m.match(m.index(0, 0), Qt.DisplayRole, name, Qt.MatchFixedString)
if listIndexes:
i = listIndexes[0]
view.selectionModel().setCurrentIndex(i, QItemSelectionModel.ClearAndSelect)
How can I select a subgroup (B, D or E) in Layers panel?
