I try to use this code from QGIS 2.x version in QGIS 3.0:
li = iface.legendInterface() li.moveLayer(demLayer, self.watershedGroupIndex
I found QgsLayerTreeLayer but can not use it. I want to move existing layer on layers panel by using gruop index, because I have layer and group index. However examples show me, adding map layer like that:
QgsProject.instance().addMapLayer(demLayer, False) root = QgsProject.instance().layerTreeRoot() group = root.findGroup(index.name()) group.insertChildNode(0, QgsLayerTreeLayer(myClone))
But I already loaded layer just want to move it to group by using its index.