Class: QgsProjectionSelectionWidget

A widget for selecting a projection.

QgsProjectionSelectionWidget

QgsProjectionSelectionWidget

Class Hierarchy

Inheritance diagram of qgis.gui.QgsProjectionSelectionWidget

Base classes

QWidget

QObject

QPaintDevice

Methods

crs

Returns the currently selected CRS for the widget

dialogTitle

Returns the title for the CRS selector dialog window.

filters

Returns the filters set on the available CRS.

optionVisible

Returns whether the specified CRS option is visible in the widget.

selectCrs

Opens the dialog for selecting a new CRS

setCrs

Sets the current CRS for the widget

setDialogTitle

Sets the title for the CRS selector dialog window.

setFilter

Sets a filtered list of CRSes to show in the widget.

setFilters

Sets filters for the available CRS.

setLayerCrs

Sets the layer CRS for the widget.

setMessage

Sets a message to show in the dialog.

setNotSetText

Sets the text to show for the not set option.

setOptionVisible

Sets whether a predefined CRS option should be shown in the widget.

setShowAccuracyWarnings

Sets whether the widget will show warnings to users when they select a CRS which has low accuracy.

setSourceEnsemble

Sets the original source ensemble datum name.

showAccuracyWarnings

Returns True if the widget will show a warning to users when they select a CRS which has low accuracy.

sourceEnsemble

Returns the original source ensemble datum name.

Signals

cleared

Emitted when the not set option is selected.

crsChanged

Emitted when the selected CRS is changed

Attributes

CrsNotSet

CurrentCrs

DefaultCrs

Invalid

LayerCrs

ProjectCrs

RecentCrs

class qgis.gui.QgsProjectionSelectionWidget[source]

Bases: QWidget

__init__(parent: QWidget | None = None, filters: QgsCoordinateReferenceSystemProxyModel.Filters | QgsCoordinateReferenceSystemProxyModel.Filter = QgsCoordinateReferenceSystemProxyModel.FilterHorizontal | QgsCoordinateReferenceSystemProxyModel.FilterCompound)

Constructor for QgsProjectionSelectionWidget, with the specified parent widget.

Since QGIS 3.36, the optional filter argument can be used to specify filters on the systems shown in the widget. The default is to show all horizontal and compound CRS in order to match the behavior of older QGIS releases. The filter can be altered to also include vertical CRS if desired.

Parameters:
CrsNotSet = 64
class CrsOption

Bases: int

CurrentCrs = 8
DefaultCrs = 16
Invalid = 1
LayerCrs = 2
ProjectCrs = 4
RecentCrs = 32
signal cleared[source]

Emitted when the not set option is selected.

crs(self) QgsCoordinateReferenceSystem[source]

Returns the currently selected CRS for the widget

Return type:

QgsCoordinateReferenceSystem

Returns:

current CRS

signal crsChanged(crs: QgsCoordinateReferenceSystem)[source]

Emitted when the selected CRS is changed

Parameters:

crs (QgsCoordinateReferenceSystem)

dialogTitle(self) str[source]

Returns the title for the CRS selector dialog window.

See also

setDialogTitle()

Added in version 3.24.

Return type:

str

filters(self) QgsCoordinateReferenceSystemProxyModel.Filters[source]

Returns the filters set on the available CRS.

See also

setFilters()

Added in version 3.36.

Return type:

QgsCoordinateReferenceSystemProxyModel.Filters

optionVisible(self, option: QgsProjectionSelectionWidget.CrsOption) bool[source]

Returns whether the specified CRS option is visible in the widget.

Parameters:

option (QgsProjectionSelectionWidget.CrsOption)

Return type:

bool

selectCrs(self)[source]

Opens the dialog for selecting a new CRS

setCrs(self, crs: QgsCoordinateReferenceSystem)[source]

Sets the current CRS for the widget

Parameters:

crs (QgsCoordinateReferenceSystem) – new CRS

setDialogTitle(self, title: str | None)[source]

Sets the title for the CRS selector dialog window.

See also

dialogTitle()

Added in version 3.24.

Parameters:

title (Optional[str])

setFilter(self, crses: Iterable[QgsCoordinateReferenceSystem])[source]

Sets a filtered list of CRSes to show in the widget.

Added in version 3.28.

Parameters:

crses (Iterable[QgsCoordinateReferenceSystem])

setFilters(self, filters: QgsCoordinateReferenceSystemProxyModel.Filters | QgsCoordinateReferenceSystemProxyModel.Filter)[source]

Sets filters for the available CRS.

See also

filters()

Added in version 3.36.

Parameters:

filters (Union[QgsCoordinateReferenceSystemProxyModel.Filters, QgsCoordinateReferenceSystemProxyModel.Filter])

setLayerCrs(self, crs: QgsCoordinateReferenceSystem)[source]

Sets the layer CRS for the widget. If set, this will be added as an option to the preset CRSes shown in the widget.

Parameters:

crs (QgsCoordinateReferenceSystem) – layer CRS

setMessage(self, text: str | None)[source]

Sets a message to show in the dialog. If an empty string is passed, the message will be a generic ‘define the CRS for this layer’.

Parameters:

text (Optional[str])

setNotSetText(self, text: str | None)[source]

Sets the text to show for the not set option. Note that this option is not shown by default and must be set visible by calling setOptionVisible().

Parameters:

text (Optional[str])

setOptionVisible(self, option: QgsProjectionSelectionWidget.CrsOption, visible: bool)[source]

Sets whether a predefined CRS option should be shown in the widget.

Parameters:

See also

optionVisible()

setShowAccuracyWarnings(self, show: bool)[source]

Sets whether the widget will show warnings to users when they select a CRS which has low accuracy.

Added in version 3.20.

Parameters:

show (bool)

setSourceEnsemble(self, ensemble: str | None)[source]

Sets the original source ensemble datum name.

If set, CRS accuracy warnings will not be shown when the selected CRS in the widget has a matching ensemble datum, regardless of the ensemble’s accuracy.

See also

sourceEnsemble()

Added in version 3.20.

Parameters:

ensemble (Optional[str])

showAccuracyWarnings(self) bool[source]

Returns True if the widget will show a warning to users when they select a CRS which has low accuracy.

Added in version 3.20.

Return type:

bool

sourceEnsemble(self) str[source]

Returns the original source ensemble datum name.

If set, CRS accuracy warnings will not be shown when the selected CRS in the widget has a matching ensemble datum, regardless of the ensemble’s accuracy.

Added in version 3.20.

Return type:

str