Class: QgsProjectUtils

Contains utility functions for working with QGIS projects.

Added in version 3.22.

Static Methods

checkUserTrust

Returns the current trust status of the specified project.

layerIsContainedInGroupLayer

Returns True if the specified layer is a child layer from any QgsGroupLayer in the given project.

layersMatchingPath

Returns a list of all layers in the specified project which match the given path.

updateLayerPath

Updates a project, replacing the data source for all layers which match the given oldPath with sources which point to newPath.

class qgis.core.QgsProjectUtils[source]

Bases: object

static checkUserTrust(project: QgsProject | None) Qgis.ProjectTrustStatus[source]

Returns the current trust status of the specified project.

Added in version 4.0.

Parameters:

project (Optional[QgsProject])

Return type:

Qgis.ProjectTrustStatus

static layerIsContainedInGroupLayer(project: QgsProject | None, layer: QgsMapLayer | None) bool[source]

Returns True if the specified layer is a child layer from any QgsGroupLayer in the given project.

Added in version 3.24.

Parameters:
Return type:

bool

static layersMatchingPath(project: QgsProject | None, path: str | None) List[QgsMapLayer]

Returns a list of all layers in the specified project which match the given path.

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]

static updateLayerPath(project: QgsProject | None, oldPath: str | None, newPath: str | None) bool[source]

Updates a project, replacing the data source for all layers which match the given oldPath with sources which point to newPath.

Returns True if any layers were updated as a result.

Parameters:
  • project (Optional[QgsProject])

  • oldPath (Optional[str])

  • newPath (Optional[str])

Return type:

bool