Class: QgsProjectionSelectionWidget

class qgis.gui.QgsProjectionSelectionWidget

Bases: PyQt5.QtWidgets.QWidget

A widget for selecting a projection.

New in version 2.7.

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

Methods

actionEvent

changeEvent

childEvent

closeEvent

connectNotify

contextMenuEvent

create

crs

Returns the currently selected CRS for the widget

customEvent

destroy

dialogTitle

Returns the title for the CRS selector dialog window.

disconnectNotify

dragEnterEvent

param event:

dragLeaveEvent

param event:

dragMoveEvent

dropEvent

param event:

enterEvent

event

filters

Returns the filters set on the available CRS.

focusInEvent

focusNextChild

focusNextPrevChild

focusOutEvent

focusPreviousChild

hideEvent

initPainter

inputMethodEvent

isSignalConnected

keyPressEvent

keyReleaseEvent

leaveEvent

metric

mouseDoubleClickEvent

mouseMoveEvent

mousePressEvent

mouseReleaseEvent

moveEvent

nativeEvent

optionVisible

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

paintEvent

receivers

resizeEvent

selectCrs

Opens the dialog for selecting a new CRS

sender

senderSignalIndex

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.

sharedPainter

showAccuracyWarnings

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

showEvent

sourceEnsemble

Returns the original source ensemble datum name.

tabletEvent

timerEvent

updateMicroFocus

wheelEvent

Signals

cleared

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

crsChanged

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

Attributes

CrsNotSet

CurrentCrs

DefaultCrs

Invalid

LayerCrs

ProjectCrs

RecentCrs

CrsNotSet = 64
class CrsOption

Bases: int

CurrentCrs = 8
DefaultCrs = 16
Invalid = 1
LayerCrs = 2
ProjectCrs = 4
RecentCrs = 32
actionEvent(self, QActionEvent)
changeEvent(self, QEvent)
childEvent(self, QChildEvent)
cleared

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

closeEvent(self, QCloseEvent)
connectNotify(self, QMetaMethod)
contextMenuEvent(self, QContextMenuEvent)
create(self, window: PyQt5.sip.voidptr = 0, initializeWindow: bool = True, destroyOldWindow: bool = True)
crs(self) QgsCoordinateReferenceSystem

Returns the currently selected CRS for the widget

Return type:

QgsCoordinateReferenceSystem

Returns:

current CRS

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

customEvent(self, QEvent)
destroy(self, destroyWindow: bool = True, destroySubWindows: bool = True)
dialogTitle(self) str

Returns the title for the CRS selector dialog window.

See also

setDialogTitle()

New in version 3.24.

Return type:

str

disconnectNotify(self, QMetaMethod)
dragEnterEvent(self, event: QDragEnterEvent)
Parameters:

event (QDragEnterEvent) –

dragLeaveEvent(self, event: QDragLeaveEvent)
Parameters:

event (QDragLeaveEvent) –

dragMoveEvent(self, QDragMoveEvent)
dropEvent(self, event: QDropEvent)
Parameters:

event (QDropEvent) –

enterEvent(self, QEvent)
event(self, QEvent) bool
filters(self) QgsCoordinateReferenceSystemProxyModel.Filters

Returns the filters set on the available CRS.

See also

setFilters()

New in version 3.36.

Return type:

QgsCoordinateReferenceSystemProxyModel.Filters

focusInEvent(self, QFocusEvent)
focusNextChild(self) bool
focusNextPrevChild(self, bool) bool
focusOutEvent(self, QFocusEvent)
focusPreviousChild(self) bool
hideEvent(self, QHideEvent)
initPainter(self, QPainter)
inputMethodEvent(self, QInputMethodEvent)
isSignalConnected(self, QMetaMethod) bool
keyPressEvent(self, QKeyEvent)
keyReleaseEvent(self, QKeyEvent)
leaveEvent(self, QEvent)
metric(self, QPaintDevice.PaintDeviceMetric) int
mouseDoubleClickEvent(self, QMouseEvent)
mouseMoveEvent(self, QMouseEvent)
mousePressEvent(self, QMouseEvent)
mouseReleaseEvent(self, QMouseEvent)
moveEvent(self, QMoveEvent)
nativeEvent(self, Union[QByteArray, bytes, bytearray], PyQt5.sip.voidptr) Tuple[bool, int]
optionVisible(self, option: QgsProjectionSelectionWidget.CrsOption) bool

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

New in version 3.0.

Parameters:

option (QgsProjectionSelectionWidget.CrsOption) –

Return type:

bool

paintEvent(self, QPaintEvent)
receivers(self, PYQT_SIGNAL) int
resizeEvent(self, QResizeEvent)
selectCrs(self)

Opens the dialog for selecting a new CRS

sender(self) QObject
senderSignalIndex(self) int
setCrs(self, crs: QgsCoordinateReferenceSystem)

Sets the current CRS for the widget

Parameters:

crs (QgsCoordinateReferenceSystem) – new CRS

setDialogTitle(self, title: str)

Sets the title for the CRS selector dialog window.

See also

dialogTitle()

New in version 3.24.

Parameters:

title (str) –

setFilter(self, crses: Iterable[QgsCoordinateReferenceSystem])

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

New in version 3.28.

Parameters:

crses (Iterable[QgsCoordinateReferenceSystem]) –

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

Sets filters for the available CRS.

See also

filters()

New in version 3.36.

Parameters:

filters (Union[QgsCoordinateReferenceSystemProxyModel.Filters) –

setLayerCrs(self, crs: QgsCoordinateReferenceSystem)

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)

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’.

New in version 3.0.

Parameters:

text (str) –

setNotSetText(self, text: str)

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().

New in version 3.0.

Parameters:

text (str) –

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

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

Parameters:

See also

optionVisible()

setShowAccuracyWarnings(self, show: bool)

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

New in version 3.20.

Parameters:

show (bool) –

setSourceEnsemble(self, ensemble: str)

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

New in version 3.20.

Parameters:

ensemble (str) –

sharedPainter(self) QPainter
showAccuracyWarnings(self) bool

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

New in version 3.20.

Return type:

bool

showEvent(self, QShowEvent)
sourceEnsemble(self) str

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.

New in version 3.20.

Return type:

str

tabletEvent(self, QTabletEvent)
timerEvent(self, QTimerEvent)
updateMicroFocus(self)
wheelEvent(self, QWheelEvent)