Class: QgsLayerTreeRegistryBridge

class qgis.core.QgsLayerTreeRegistryBridge(root: QgsLayerTreeGroup, project: QgsProject, parent: QObject = None)

Bases: PyQt5.QtCore.QObject

Create the instance that synchronizes given project with a layer tree root

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.

New in version 2.4.

Parameters
class InsertionPoint(group: QgsLayerTreeGroup, position: int)

Bases: sip.wrapper

Construcs an insertion point as layer tree group with its corresponding position.

QgsLayerTreeRegistryBridge.InsertionPoint(QgsLayerTreeRegistryBridge.InsertionPoint)

Parameters
group
position
addedLayersToLayerTree

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

New in version 2.6: [signal]

Parameters

layers (Iterable[QgsMapLayer]) –

childEvent(self, QChildEvent)
connectNotify(self, QMetaMethod)
customEvent(self, QEvent)
disconnectNotify(self, QMetaMethod)
groupRemovedChildren(self)
groupWillRemoveChildren(self, node: QgsLayerTreeNode, indexFrom: int, indexTo: int)
Parameters
isEnabled(self) → bool
Return type

bool

isSignalConnected(self, QMetaMethod) → bool
layersAdded(self, layers: Iterable[QgsMapLayer])
Parameters

layers (Iterable[QgsMapLayer]) –

layersWillBeRemoved(self, layerIds: Iterable[str])
Parameters

layerIds (Iterable[str]) –

newLayersVisible(self) → bool
Return type

bool

receivers(self, PYQT_SIGNAL) → int
removeLayersFromRegistry(self, layerIds: Iterable[str])
Parameters

layerIds (Iterable[str]) –

sender(self) → QObject
senderSignalIndex(self) → int
setEnabled(self, enabled: bool)
Parameters

enabled (bool) –

setLayerInsertionPoint(self, parentGroup: QgsLayerTreeGroup, index: int)

Set where the new layers should be inserted - can be used to follow current selection. By default it is root group with zero index.

Deprecated since version QGIS: 3.10 use setLayerInsertionPoint( const InsertionPoint &insertionPoint ) instead

setLayerInsertionPoint(self, insertionPoint: QgsLayerTreeRegistryBridge.InsertionPoint) Set where the new layers should be inserted - can be used to follow current selection. By default it is root group with zero index.

New in version 3.10.

Parameters
setNewLayersVisible(self, enabled: bool)
Parameters

enabled (bool) –

timerEvent(self, QTimerEvent)