Class: QgsCrsSelectionWidget

A generic widget allowing users to pick a Coordinate Reference System (or define their own).

Added in version 3.24.

QgsCrsSelectionWidget

QgsCrsSelectionWidget

Class Hierarchy

Inheritance diagram of qgis.gui.QgsCrsSelectionWidget

Base classes

QgsPanelWidget

Base class for any widget that can be shown as an inline panel.

QWidget

QObject

QPaintDevice

class qgis.gui.QgsCrsSelectionWidget[source]

Bases: QgsPanelWidget

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

Constructor for QgsCrsSelectionWidget, 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:
crs(self) QgsCoordinateReferenceSystem[source]

Returns the CRS currently selected in the widget.

See also

setCrs()

Return type:

QgsCoordinateReferenceSystem

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.

signal crsDoubleClicked[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.

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

hasValidSelection(self) bool[source]

Returns True if the widget has a valid CRS defined.

Return type:

bool

signal hasValidSelectionChanged[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.

setCrs(self, crs: QgsCoordinateReferenceSystem)[source]

Sets the crs to show within the widget.

See also

crs()

Parameters:

crs (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])

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

Sets a message to show in the dialog.

Parameters:

message (Optional[str])

setNotSetText(self, text: str | None, description: 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 setShowNoCrs().

The description argument can be used to specify a detailed description which is shown when the option is selected.

Parameters:
  • text (Optional[str])

  • description (Optional[str] = '')

setOgcWmsCrsFilter(self, crsFilter: Iterable[str | None])[source]

filters this dialog by the given CRSs

Sets this dialog to filter the available CRSs to those listed by the given Coordinate Reference Systems.

Parameters:

crsFilter (Iterable[Optional[str]]) – a list of OGC Coordinate Reference Systems to filter the list of CRS by. This is useful in (e.g.) WMS situations where you just want to offer what the WMS server can support.

Warning

This function’s behavior is undefined if it is called after the dialog is shown.

setShowNoCrs(self, show: bool)[source]

Sets whether a “no/invalid” CRS option should be shown. If this option is selected, calling crs() will return an invalid QgsCoordinateReferenceSystem.

See also

showNoCrs()

Parameters:

show (bool)

showNoCrs(self) bool[source]

Returns whether the “no/invalid” CRS option is shown. If this option is selected, calling crs() will return an invalid QgsCoordinateReferenceSystem.

See also

setShowNoCrs()

Return type:

bool