If in QGIS TOC a group already exists and I add a new layer via
QgsVectorLayer* lyr= mQGisIface->addVectorLayer(uri->uri(),Title, myProviderName);
the new layer will be inserted within the group. How can I move it outside/above the group?
pyqgisqgistable of contents
If in QGIS TOC a group already exists and I add a new layer via
QgsVectorLayer* lyr= mQGisIface->addVectorLayer(uri->uri(),Title, myProviderName);
the new layer will be inserted within the group. How can I move it outside/above the group?
Best Answer
You can do that by following these steps (QGIS >= v.2.4):
Get the layer tree object
Find the desired group by name
Get the group index
Create the new layer object
Add the layer to the QGIS Map Layer Registry
Insert the layer above the group