Class: QgsProjectViewSettings

Contains settings and properties relating to how a QgsProject should be displayed inside map canvas, e.g. map scales and default view extent for the project.

Added in version 3.10.1.

Class Hierarchy

Inheritance diagram of qgis.core.QgsProjectViewSettings

Base classes

QObject

Methods

defaultRotation

Returns the default map rotation (in clockwise degrees) for maps in the project.

defaultViewExtent

Returns the default view extent, which should be used as the initial map extent when this project is opened.

fullExtent

Returns the full extent of the project, which represents the maximal limits of the project.

mapScales

Returns the list of custom project map scales.

presetFullExtent

Returns the project's preset full extent.

readXml

Reads the settings's state from a DOM element.

reset

Resets the settings to a default state.

setDefaultRotation

Set the default rotation of maps in the project, in clockwise degrees.

setDefaultViewExtent

Sets the default view extent, which should be used as the initial map extent when this project is opened.

setMapScales

Sets the list of custom project map scales.

setPresetFullExtent

Sets the project's preset full extent.

setUseProjectScales

Sets whether project mapScales() are enabled.

useProjectScales

Returns True if project mapScales() are enabled.

writeXml

Returns a DOM element representing the settings.

Signals

mapScalesChanged

Emitted when the list of custom project map scales changes.

presetFullExtentChanged

Emitted whenever the presetFullExtent() is changed.

class qgis.core.QgsProjectViewSettings[source]

Bases: QObject

__init__(project: QgsProject | None = None)

Constructor for QgsProjectViewSettings for the specified project.

Ownership is transferred to the project.

Parameters:

project (Optional[QgsProject] = None)

defaultRotation(self) float[source]

Returns the default map rotation (in clockwise degrees) for maps in the project.

Warning

When a project is opened in the QGIS desktop application and saved, individual map canvases will store their own previous map rotations as custom project properties. Reloading this saved version of the project will trigger the canvases to restore their individual rotations. Accordingly, in the QGIS desktop application, this setting only forms a default, initial view used when the project is opened for the very first time (or when new map canvases are opened in that project.)

Added in version 3.28.

Return type:

float

defaultViewExtent(self) QgsReferencedRectangle[source]

Returns the default view extent, which should be used as the initial map extent when this project is opened.

Warning

When a project is opened in the QGIS desktop application and saved, individual map canvases will store their own previous view extent as custom project properties. Reloading this saved version of the project will trigger the canvases to restore their individual last view extents. Accordingly, in the QGIS desktop application, this setting only forms a default, initial view used when the project is opened for the very first time.

Return type:

QgsReferencedRectangle

fullExtent(self) QgsReferencedRectangle[source]

Returns the full extent of the project, which represents the maximal limits of the project.

The returned extent will be in the project’s CRS.

If the presetFullExtent() is non null, this will be returned as the full extent. Otherwise the full extent will be calculated based on the extent of all layers in the project.

Return type:

QgsReferencedRectangle

mapScales(self) List[float]

Returns the list of custom project map scales.

The scales list consists of a list of scale denominator values, e.g. 1000 for a 1:1000 scale.

See also

setMapScales()

Return type:

List[float]

signal mapScalesChanged[source]

Emitted when the list of custom project map scales changes.

See also

mapScales()

See also

setMapScales()

presetFullExtent(self) QgsReferencedRectangle[source]

Returns the project’s preset full extent.

This extent represents the maximal limits of the project. The full extent defaults to a null rectangle, which indicates that the maximal extent should be calculated based on the layers in the project.

See also

fullExtent()

Added in version 3.18.

Return type:

QgsReferencedRectangle

signal presetFullExtentChanged[source]

Emitted whenever the presetFullExtent() is changed.

Added in version 3.18.

readXml(self, element: QDomElement, context: QgsReadWriteContext) bool[source]

Reads the settings’s state from a DOM element.

See also

writeXml()

Parameters:
Return type:

bool

reset(self)[source]

Resets the settings to a default state.

setDefaultRotation(self, rotation: float)[source]

Set the default rotation of maps in the project, in clockwise degrees.

Warning

When a project is opened in the QGIS desktop application and saved, individual map canvases will store their own previous map rotations as custom project properties. Reloading this saved version of the project will trigger the canvases to restore their individual rotations. Accordingly, in the QGIS desktop application, this setting only forms a default, initial view used when the project is opened for the very first time (or when new map canvases are opened in that project.)

Added in version 3.28.

Parameters:

rotation (float)

setDefaultViewExtent(self, extent: QgsReferencedRectangle)[source]

Sets the default view extent, which should be used as the initial map extent when this project is opened.

Warning

When a project is opened in the QGIS desktop application and saved, individual map canvases will store their own previous view extent as custom project properties. Reloading this saved version of the project will trigger the canvases to restore their individual last view extents. Accordingly, in the QGIS desktop application, this setting only forms a default, initial view used when the project is opened for the very first time.

Parameters:

extent (QgsReferencedRectangle)

setMapScales(self, scales: Iterable[float])[source]

Sets the list of custom project map scales.

The scales list consists of a list of scale denominator values, e.g. 1000 for a 1:1000 scale.

See also

mapScales()

Parameters:

scales (Iterable[float])

setPresetFullExtent(self, extent: QgsReferencedRectangle)[source]

Sets the project’s preset full extent.

This extent represents the maximal limits of the project. Setting the full extent to a null rectangle indicates that the maximal extent should be calculated based on the layers in the project.

See also

fullExtent()

Added in version 3.18.

Parameters:

extent (QgsReferencedRectangle)

setUseProjectScales(self, enabled: bool)[source]

Sets whether project mapScales() are enabled.

When project map scales are enabled these scales will replace the default QGIS map scales list while working with this project.

See also

setMapScales()

Parameters:

enabled (bool)

useProjectScales(self) bool[source]

Returns True if project mapScales() are enabled.

When project map scales are enabled these scales will replace the default QGIS map scales list while working with this project.

See also

mapScales()

Return type:

bool

writeXml(self, doc: QDomDocument, context: QgsReadWriteContext) QDomElement[source]

Returns a DOM element representing the settings.

See also

readXml()

Parameters:
Return type:

QDomElement