Class: QgsLayerTreeMapCanvasBridge

class qgis.gui.QgsLayerTreeMapCanvasBridge

Bases: PyQt5.QtCore.QObject

The QgsLayerTreeMapCanvasBridge class takes care of updates of layer set for QgsMapCanvas from a layer tree. The class listens to the updates in the layer tree and updates the list of layers for rendering whenever some layers are added, removed, or their visibility changes.

The update of layers is not done immediately - it is postponed, so a series of updates to the layer tree will trigger just one update of canvas layers.

Also allows the client to override the default order of layers. This is useful in advanced cases where the grouping in layer tree should be independent from the actual order in the canvas.

QgsLayerTreeMapCanvasBridge(root: Optional[QgsLayerTree], canvas: Optional[QgsMapCanvas], parent: Optional[QObject] = None) Constructor: does not take ownership of the layer tree nor canvas

Methods

autoSetupOnFirstLayer

rtype:

bool

childEvent

connectNotify

customEvent

disconnectNotify

isSignalConnected

mapCanvas

rtype:

Optional[QgsMapCanvas]

overviewCanvas

Returns associated overview canvas (may be None)

receivers

rootGroup

rtype:

Optional[QgsLayerTree]

sender

senderSignalIndex

setAutoSetupOnFirstLayer

if enabled, will automatically set full canvas extent and destination CRS + map units when first layer(s) are added

setCanvasLayers

force update of canvas layers from the layer tree.

setOvervewCanvas

param overviewCanvas:

setOverviewCanvas

Associates overview canvas with the bridge, so the overview will be updated whenever main canvas is updated

timerEvent

Signals

canvasLayersChanged

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

autoSetupOnFirstLayer(self) bool
Return type:

bool

canvasLayersChanged

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Parameters:
  • name (str = ...)

  • revision (int = ...)

  • arguments (Sequence = ...)

Return type:

PYQT_SIGNAL

childEvent(self, a0: QChildEvent | None)
connectNotify(self, signal: QMetaMethod)
customEvent(self, a0: QEvent | None)
disconnectNotify(self, signal: QMetaMethod)
isSignalConnected(self, signal: QMetaMethod) bool
mapCanvas(self) QgsMapCanvas | None
Return type:

Optional[QgsMapCanvas]

overviewCanvas(self) QgsMapOverviewCanvas | None

Returns associated overview canvas (may be None)

Return type:

Optional[QgsMapOverviewCanvas]

receivers(self, signal: PYQT_SIGNAL) int
rootGroup(self) QgsLayerTree | None
Return type:

Optional[QgsLayerTree]

sender(self) QObject | None
senderSignalIndex(self) int
setAutoSetupOnFirstLayer(self, enabled: bool)

if enabled, will automatically set full canvas extent and destination CRS + map units when first layer(s) are added

Parameters:

enabled (bool)

setCanvasLayers(self)

force update of canvas layers from the layer tree. Normally this should not be needed to be called.

setOvervewCanvas(self, overviewCanvas: QgsMapOverviewCanvas | None)
Parameters:

overviewCanvas (Optional[QgsMapOverviewCanvas])

setOverviewCanvas(self, overviewCanvas: QgsMapOverviewCanvas | None)

Associates overview canvas with the bridge, so the overview will be updated whenever main canvas is updated

Added in version 3.6.

Parameters:

overviewCanvas (Optional[QgsMapOverviewCanvas])

timerEvent(self, a0: QTimerEvent | None)