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 a inline panel

QWidget

QObject

QPaintDevice

Methods

crs

Returns the CRS currently selected in the widget.

filters

Returns the filters set on the available CRS.

hasValidSelection

Returns True if the widget has a valid CRS defined.

setCrs

Sets the crs to show within the widget.

setFilters

Sets filters for the available CRS.

setMessage

Sets a message to show in the dialog.

setNotSetText

Sets the text to show for the not set option.

setOgcWmsCrsFilter

filters this dialog by the given CRSs

setShowNoCrs

Sets whether a "no/invalid" CRS option should be shown.

showNoCrs

Returns whether the "no/invalid" CRS option is shown.

Signals

crsChanged

Emitted when the CRS defined in the widget is changed.

crsDoubleClicked

Emitted when a CRS entry in the widget is double-clicked.

hasValidSelectionChanged

Emitted when the widget has a valid selection or not.

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]

Emitted when the CRS defined in the widget is changed.

signal crsDoubleClicked(crs: QgsCoordinateReferenceSystem)[source]

Emitted when a CRS entry in the widget is double-clicked.

Parameters:

crs (QgsCoordinateReferenceSystem)

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(isValid: bool)[source]

Emitted when the widget has a valid selection or not.

Parameters:

isValid (bool)

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