Class: QgsProjectUtils¶
- class qgis.core.QgsProjectUtils¶
Bases:
sip.wrapper
Contains utility functions for working with QGIS projects.
Added in version 3.22:
Methods
Returns
True
if the specifiedlayer
is a child layer from anyQgsGroupLayer
in the givenproject
.Returns a list of all layers in the specified
project
which match the givenpath
.Updates a
project
, replacing the data source for all layers which match the givenoldPath
with sources which point tonewPath
.- layerIsContainedInGroupLayer(project: QgsProject | None, layer: QgsMapLayer | None) bool ¶
Returns
True
if the specifiedlayer
is a child layer from anyQgsGroupLayer
in the givenproject
.Added in version 3.24.
- Parameters:
project (Optional[QgsProject])
layer (Optional[QgsMapLayer])
- Return type:
bool
- layersMatchingPath(project: QgsProject | None, path: str | None) List[QgsMapLayer] ¶
Returns a list of all layers in the specified
project
which match the givenpath
.This method can be used to retrieve a list of layers in a project associated with a file path.
- Parameters:
project (Optional[QgsProject])
path (Optional[str])
- Return type:
List[QgsMapLayer]
- updateLayerPath(project: QgsProject | None, oldPath: str | None, newPath: str | None) bool ¶
Updates a
project
, replacing the data source for all layers which match the givenoldPath
with sources which point tonewPath
.Returns
True
if any layers were updated as a result.- Parameters:
project (Optional[QgsProject])
oldPath (Optional[str])
newPath (Optional[str])
- Return type:
bool