Class: QgsCrsSelectionWidget

class qgis.gui.QgsCrsSelectionWidget

Bases: QgsPanelWidget

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

Added in version 3.24.

QgsCrsSelectionWidget(parent: Optional[QWidget] = None, filters: Union[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.

Methods

actionEvent

changeEvent

childEvent

closeEvent

connectNotify

contextMenuEvent

create

crs

Returns the CRS currently selected in the widget.

customEvent

destroy

disconnectNotify

dragEnterEvent

dragLeaveEvent

dragMoveEvent

dropEvent

enterEvent

event

filters

Returns the filters set on the available CRS.

focusInEvent

focusNextChild

focusNextPrevChild

focusOutEvent

focusPreviousChild

hasValidSelection

Returns True if the widget has a valid CRS defined.

hideEvent

initPainter

inputMethodEvent

isSignalConnected

keyPressEvent

Overridden key press event to handle the esc event on the widget.

keyReleaseEvent

leaveEvent

metric

mouseDoubleClickEvent

mouseMoveEvent

mousePressEvent

mouseReleaseEvent

moveEvent

nativeEvent

paintEvent

receivers

resizeEvent

sender

senderSignalIndex

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.

sharedPainter

showEvent

showNoCrs

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

tabletEvent

timerEvent

updateMicroFocus

wheelEvent

Signals

crsChanged

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

crsDoubleClicked

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

hasValidSelectionChanged

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

actionEvent(self, a0: QActionEvent | None)
changeEvent(self, a0: QEvent | None)
childEvent(self, a0: QChildEvent | None)
closeEvent(self, a0: QCloseEvent | None)
connectNotify(self, signal: QMetaMethod)
contextMenuEvent(self, a0: QContextMenuEvent | None)
create(self, window: PyQt5.sip.voidptr = None, initializeWindow: bool = True, destroyOldWindow: bool = True)
crs(self) QgsCoordinateReferenceSystem

Returns the CRS currently selected in the widget.

See also

setCrs()

Return type:

QgsCoordinateReferenceSystem

crsChanged

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.

Parameters:
  • name (str = ...)

  • revision (int = ...)

  • arguments (Sequence = ...)

Return type:

PYQT_SIGNAL

crsDoubleClicked

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.

Parameters:
  • name (str = ...)

  • revision (int = ...)

  • arguments (Sequence = ...)

Return type:

PYQT_SIGNAL

customEvent(self, a0: QEvent | None)
destroy(self, destroyWindow: bool = True, destroySubWindows: bool = True)
disconnectNotify(self, signal: QMetaMethod)
dragEnterEvent(self, a0: QDragEnterEvent | None)
dragLeaveEvent(self, a0: QDragLeaveEvent | None)
dragMoveEvent(self, a0: QDragMoveEvent | None)
dropEvent(self, a0: QDropEvent | None)
enterEvent(self, a0: QEvent | None)
event(self, a0: QEvent | None) bool
filters(self) QgsCoordinateReferenceSystemProxyModel.Filters

Returns the filters set on the available CRS.

See also

setFilters()

Added in version 3.36.

Return type:

QgsCoordinateReferenceSystemProxyModel.Filters

focusInEvent(self, a0: QFocusEvent | None)
focusNextChild(self) bool
focusNextPrevChild(self, next: bool) bool
focusOutEvent(self, a0: QFocusEvent | None)
focusPreviousChild(self) bool
hasValidSelection(self) bool

Returns True if the widget has a valid CRS defined.

Return type:

bool

hasValidSelectionChanged

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.

Parameters:
  • name (str = ...)

  • revision (int = ...)

  • arguments (Sequence = ...)

Return type:

PYQT_SIGNAL

hideEvent(self, a0: QHideEvent | None)
initPainter(self, painter: QPainter | None)
inputMethodEvent(self, a0: QInputMethodEvent | None)
isSignalConnected(self, signal: QMetaMethod) bool
keyPressEvent(self, event: QKeyEvent | None)

Overridden key press event to handle the esc event on the widget.

Parameters:

event – The key event

keyReleaseEvent(self, a0: QKeyEvent | None)
leaveEvent(self, a0: QEvent | None)
metric(self, a0: QPaintDevice.PaintDeviceMetric) int
mouseDoubleClickEvent(self, a0: QMouseEvent | None)
mouseMoveEvent(self, a0: QMouseEvent | None)
mousePressEvent(self, a0: QMouseEvent | None)
mouseReleaseEvent(self, a0: QMouseEvent | None)
moveEvent(self, a0: QMoveEvent | None)
nativeEvent(self, eventType: QByteArray | bytes | bytearray, message: PyQt5.sip.voidptr | None)
paintEvent(self, a0: QPaintEvent | None)
receivers(self, signal: PYQT_SIGNAL) int
resizeEvent(self, a0: QResizeEvent | None)
sender(self) QObject | None
senderSignalIndex(self) int
setCrs(self, crs: QgsCoordinateReferenceSystem)

Sets the crs to show within the widget.

See also

crs()

Parameters:

crs (QgsCoordinateReferenceSystem)

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

Sets filters for the available CRS.

See also

filters()

Added in version 3.36.

Parameters:

filters (Union[QgsCoordinateReferenceSystemProxyModel.Filters)

setMessage(self, message: str | None)

Sets a message to show in the dialog.

Parameters:

message (Optional[str])

setNotSetText(self, text: str | None, description: str | None = '')

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

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)

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)

sharedPainter(self) QPainter | None
showEvent(self, a0: QShowEvent | None)
showNoCrs(self) bool

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

tabletEvent(self, a0: QTabletEvent | None)
timerEvent(self, a0: QTimerEvent | None)
updateMicroFocus(self)
wheelEvent(self, a0: QWheelEvent | None)