Class: QgsProjectionSelectionWidget

A widget for selecting a projection.

QgsProjectionSelectionWidget

QgsProjectionSelectionWidget

Class Hierarchy

Inheritance diagram of qgis.gui.QgsProjectionSelectionWidget

Base classes

QWidget

QObject

QPaintDevice

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]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

crs(self) QgsCoordinateReferenceSystem[source]

Returns the currently selected CRS for the widget

Return type:

QgsCoordinateReferenceSystem

Returns:

current CRS

signal crsChanged[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

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