Class: QgsGroupLayer¶
- class qgis.core.QgsGroupLayer¶
Bases:
QgsMapLayer
A map layer which consists of a set of child layers, where all component layers are rendered as a single flattened object during map renders.
Child layers are never owned by
QgsGroupLayer
. References to layers in a group are stored as weak references only, which wills be automatically cleaned up whenever the linked child layer is deleted.New in version 3.24.
QgsGroupLayer(name: str, options: QgsGroupLayer.LayerOptions) Constructor for a new
QgsGroupLayer
with the specified layername
.The
options
argument specifies load-time layer options.Methods
Add error message
Returns the child layers contained by the group.
- rtype
QgsGroupLayer
- param rendererContext
- rtype
QgsDataProvider
Called by
readLayerXML()
, used by derived classes to decode provider's specific data source from project files.Called by
writeLayerXML()
, used by derived classes to encode provider's specific data source to project files.- rtype
QgsRectangle
Checks whether a new set of dependencies will introduce a cycle this method is now deprecated and always return
False
, because circular dependencies are now correctly managed.- rtype
str
Invalidates the WGS84 extent.
Returns the current paint effect for the group layer.
Read style data common to all layer types
Read custom properties from project file.
Read style manager's configuration (if any).
- param node
- param layerNode
- param project
Sets the child
layers
contained by the group.Sets error message
Sets the extent
Sets the current paint
effect
for the renderer.Sets the
providerType
(provider key)- param context
Sets whether layer is valid or not
Write style data common to all layer types
Write custom properties to project file.
Write style manager's configuration (if exists).
- param node
- param layer_node
- class LayerOptions(transformContext: QgsCoordinateTransformContext)¶
Bases:
sip.wrapper
Constructor for LayerOptions.
QgsGroupLayer.LayerOptions(QgsGroupLayer.LayerOptions)
- transformContext¶
- appendError(self, error: QgsErrorMessage)¶
Add error message
- childEvent(self, QChildEvent)¶
- childLayers(self) List[QgsMapLayer] ¶
Returns the child layers contained by the group.
See also
- Return type
List[QgsMapLayer]
- clone(self) QgsGroupLayer ¶
- Return type
- connectNotify(self, QMetaMethod)¶
- createMapRenderer(self, rendererContext: QgsRenderContext) QgsMapLayerRenderer ¶
- Parameters
rendererContext (QgsRenderContext) –
- Return type
- customEvent(self, QEvent)¶
- dataProvider(self) QgsDataProvider ¶
- Return type
- decodedSource(self, source: str, dataProvider: str, context: QgsReadWriteContext) str ¶
Called by
readLayerXML()
, used by derived classes to decode provider’s specific data source from project files. Typically resolving absolute or relative paths, usernames and passwords or drivers prefixes (“HDF5:”)- Parameters
source – data source to decode, typically read from layer’s DOM element “datasource”
dataProvider – string identification of data provider (e.g. “ogr”), typically read from layer’s DOM element
context – reading context (e.g. for conversion between relative and absolute paths)
- Returns
decoded source, typically to be used as the layer’s datasource
New in version 3.2.
- disconnectNotify(self, QMetaMethod)¶
- encodedSource(self, source: str, context: QgsReadWriteContext) str ¶
Called by
writeLayerXML()
, used by derived classes to encode provider’s specific data source to project files. Typically resolving absolute or relative paths, usernames and passwords or drivers prefixes (“HDF5:”)- Parameters
source – data source to encode, typically
QgsMapLayer.source()
context – writing context (e.g. for conversion between relative and absolute paths)
- Returns
encoded source, typically to be written in the DOM element “datasource”
New in version 3.2.
- extent(self) QgsRectangle ¶
- Return type
- hasDependencyCycle(self, Iterable[QgsMapLayerDependency]) bool ¶
Checks whether a new set of dependencies will introduce a cycle this method is now deprecated and always return
False
, because circular dependencies are now correctly managed.Deprecated since version QGIS: 3.10
- htmlMetadata(self) str ¶
- Return type
str
- invalidateWgs84Extent(self)¶
Invalidates the WGS84 extent. If FlagTrustLayerMetadata is enabled, the extent is not invalidated because we want to trust metadata whatever happens.
New in version 3.20.
- isSignalConnected(self, QMetaMethod) bool ¶
- paintEffect(self) QgsPaintEffect ¶
Returns the current paint effect for the group layer.
See also
- Return type
- readCommonStyle(self, layerElement: QDomElement, context: QgsReadWriteContext, categories: Union[QgsMapLayer.StyleCategories, QgsMapLayer.StyleCategory] = QgsMapLayer.AllStyleCategories)¶
Read style data common to all layer types
New in version 3.0.
- readCustomProperties(self, layerNode: QDomNode, keyStartsWith: str = '')¶
Read custom properties from project file.
- Parameters
layerNode – note to read from
keyStartsWith – reads only properties starting with the specified string (or all if the string is empty)
- readStyleManager(self, layerNode: QDomNode)¶
Read style manager’s configuration (if any). To be called by subclasses.
- readSymbology(self, node: QDomNode, errorMessage: str, context: QgsReadWriteContext, categories: Union[QgsMapLayer.StyleCategories, QgsMapLayer.StyleCategory] = QgsMapLayer.AllStyleCategories) bool ¶
- Parameters
node (QDomNode) –
errorMessage (str) –
context (QgsReadWriteContext) –
categories (Union[QgsMapLayer.StyleCategories) –
- Return type
bool
- readXml(self, layerNode: QDomNode, context: QgsReadWriteContext) bool ¶
- Parameters
layerNode (QDomNode) –
context (QgsReadWriteContext) –
- Return type
bool
- receivers(self, PYQT_SIGNAL) int ¶
- resolveReferences(self, project: QgsProject)¶
- Parameters
project (QgsProject) –
- sender(self) QObject ¶
- senderSignalIndex(self) int ¶
- setChildLayers(self, layers: Iterable[QgsMapLayer])¶
Sets the child
layers
contained by the group.This method does not take ownership of the layers, but rather assigns them to the group. Layers should be already added to the parent
QgsProject
wherever appropriate.See also
- Parameters
layers (Iterable[QgsMapLayer]) –
- setExtent(self, rect: QgsRectangle)¶
Sets the extent
- setPaintEffect(self, effect: QgsPaintEffect)¶
Sets the current paint
effect
for the renderer.Ownership is transferred to the renderer.
See also
- Parameters
effect (QgsPaintEffect) –
- setProviderType(self, providerType: str)¶
Sets the
providerType
(provider key)
- setTransformContext(self, context: QgsCoordinateTransformContext)¶
- Parameters
context (QgsCoordinateTransformContext) –
- setValid(self, valid: bool)¶
Sets whether layer is valid or not
- timerEvent(self, QTimerEvent)¶
- writeCommonStyle(self, layerElement: QDomElement, document: QDomDocument, context: QgsReadWriteContext, categories: Union[QgsMapLayer.StyleCategories, QgsMapLayer.StyleCategory] = QgsMapLayer.AllStyleCategories)¶
Write style data common to all layer types
New in version 3.0.
- writeCustomProperties(self, layerNode: QDomNode, doc: QDomDocument)¶
Write custom properties to project file.
- writeStyleManager(self, layerNode: QDomNode, doc: QDomDocument)¶
Write style manager’s configuration (if exists). To be called by subclasses.
- writeSymbology(self, node: QDomNode, doc: QDomDocument, errorMessage: str, a3: QgsReadWriteContext, categories: Union[QgsMapLayer.StyleCategories, QgsMapLayer.StyleCategory] = QgsMapLayer.AllStyleCategories) bool ¶
- Parameters
node (QDomNode) –
doc (QDomDocument) –
errorMessage (str) –
a3 (QgsReadWriteContext) –
categories (Union[QgsMapLayer.StyleCategories) –
- Return type
bool
- writeXml(self, layer_node: QDomNode, doc: QDomDocument, context: QgsReadWriteContext) bool ¶
- Parameters
layer_node (QDomNode) –
doc (QDomDocument) –
context (QgsReadWriteContext) –
- Return type
bool