QgsLayerTreeRegistryBridge class

Listens to the updates in map layer registry and does changes in layer tree.

When connected to a layer tree, any layers added to the map layer registry will be also added to the layer tree. Similarly, map layers that are removed from registry will be removed from the layer tree.

If a layer is completely removed from the layer tree, it will be also removed from the map layer registry.

Constructors, destructors, conversion operators

QgsLayerTreeRegistryBridge(QgsLayerTreeGroup* root, QgsProject* project, QObject* parent = nullptr) explicit
Create the instance that synchronizes given project with a layer tree root.

Public functions

void setLayerInsertionPoint(QgsLayerTreeGroup* parentGroup, int index)
Set where the new layers should be inserted - can be used to follow current selection.

Signals

void addedLayersToLayerTree(const QList<QgsMapLayer*>& layers)
Tell others we have just added layers to the tree (used in QGIS to auto-select first newly added layer)

Function documentation

void QgsLayerTreeRegistryBridge::setLayerInsertionPoint(QgsLayerTreeGroup* parentGroup, int index)

Set where the new layers should be inserted - can be used to follow current selection.

By default it is root group with zero index.

void QgsLayerTreeRegistryBridge::addedLayersToLayerTree(const QList<QgsMapLayer*>& layers) signal

Tell others we have just added layers to the tree (used in QGIS to auto-select first newly added layer)