Class: QgsLayerTreeRegistryBridge¶
Listens to layer changes from a QgsProject
and applies
changes to a QgsLayerTree
.
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.
Class Hierarchy¶
Base classes¶
Methods
Returns the insertion method used to add layers to the tree |
|
Returns the insertion point used to add layers to the tree |
|
Sets the insertion method used to add layers to the tree |
|
Set where the new layers should be inserted - can be used to follow current selection. |
|
Signals
Tell others we have just added layers to the tree (used in QGIS to auto-select first newly added layer) |
- class qgis.core.QgsLayerTreeRegistryBridge[source]¶
Bases:
QObject
- __init__(root: QgsLayerTreeGroup | None, project: QgsProject | None, parent: QObject | None = None)
Create the instance that synchronizes given project with a layer tree root
- Parameters:
root (Optional[QgsLayerTreeGroup])
project (Optional[QgsProject])
parent (Optional[QObject] = None)
- class InsertionPoint¶
Bases:
object
A structure to define the insertion point to the layer tree. This represents the current layer tree group and index where newly added map layers should be inserted into.
Added in version 3.10.
- group¶
- position¶
- signal addedLayersToLayerTree(layers: List[QgsMapLayer])[source]¶
Tell others we have just added layers to the tree (used in QGIS to auto-select first newly added layer)
- Parameters:
layers (List[QgsMapLayer])
- groupWillRemoveChildren(self, node: QgsLayerTreeNode | None, indexFrom: int, indexTo: int)[source]¶
- Parameters:
node (Optional[QgsLayerTreeNode])
indexFrom (int)
indexTo (int)
- layerInsertionMethod(self) Qgis.LayerTreeInsertionMethod [source]¶
Returns the insertion method used to add layers to the tree
Added in version 3.30.
- Return type:
- layerInsertionPoint(self) QgsLayerTreeRegistryBridge.InsertionPoint [source]¶
Returns the insertion point used to add layers to the tree
Added in version 3.42.
- Return type:
- layersAdded(self, layers: Iterable[QgsMapLayer])[source]¶
- Parameters:
layers (Iterable[QgsMapLayer])
- layersWillBeRemoved(self, layerIds: Iterable[str | None])[source]¶
- Parameters:
layerIds (Iterable[Optional[str]])
- removeLayersFromRegistry(self, layerIds: Iterable[str | None])[source]¶
- Parameters:
layerIds (Iterable[Optional[str]])
- setLayerInsertionMethod(self, method: Qgis.LayerTreeInsertionMethod)[source]¶
Sets the insertion
method
used to add layers to the treeAdded in version 3.30.
- Parameters:
method (Qgis.LayerTreeInsertionMethod)
- setLayerInsertionPoint(self, parentGroup: QgsLayerTreeGroup | None, index: int)[source]¶
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 3.10: Use setLayerInsertionPoint( const InsertionPoint &insertionPoint ) instead.
- Parameters:
parentGroup (Optional[QgsLayerTreeGroup])
index (int)
- setLayerInsertionPoint(self, insertionPoint: QgsLayerTreeRegistryBridge.InsertionPoint)[source]
Set where the new layers should be inserted - can be used to follow current selection. By default it is root group with zero index.
Added in version 3.10.
- Parameters:
insertionPoint (QgsLayerTreeRegistryBridge.InsertionPoint)