Class: QgsProjectionSelectionDialog

class qgis.gui.QgsProjectionSelectionDialog

Bases: PyQt5.QtWidgets.QDialog

A generic dialog to prompt the user for a Coordinate Reference System.

Typically you will use this when you want to prompt the user for a coordinate system identifier e.g. from a plugin you might do this to get an epsg code:

crs = QgsCoordinateReferenceSystem()
mySelector = QgsProjectionSelectionDialog( iface.mainWindow() )
mySelector.setCrs( crs )
if mySelector.exec():
  mCrs = mySelector.crs()

If you wish to embed the projection selector into an existing dialog the you probably want to look at QgsProjectionSelectionWidget instead.

QgsProjectionSelectionDialog(parent: QWidget = None, fl: Union[Qt.WindowFlags, Qt.WindowType] = QgsGuiUtils.ModalDialogFlags, filters: Union[QgsCoordinateReferenceSystemProxyModel.Filters, QgsCoordinateReferenceSystemProxyModel.Filter] = QgsCoordinateReferenceSystemProxyModel.FilterHorizontal|QgsCoordinateReferenceSystemProxyModel.FilterCompound) Constructor for QgsProjectionSelectionDialog.

Since QGIS 3.36, the optional filter argument can be used to specify filters on the systems shown in the dialog. 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

eventFilter

filters

Returns the filters set on the available CRS.

focusInEvent

focusNextChild

focusNextPrevChild

focusOutEvent

focusPreviousChild

hasValidSelection

Returns True if the dialog has a valid CRS defined.

hideEvent

initPainter

inputMethodEvent

isSignalConnected

keyPressEvent

keyReleaseEvent

leaveEvent

metric

mouseDoubleClickEvent

mouseMoveEvent

mousePressEvent

mouseReleaseEvent

moveEvent

nativeEvent

paintEvent

receivers

resizeEvent

sender

senderSignalIndex

setCrs

Sets the initial crs to show within the dialog.

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

setRequireValidSelection

Sets the dialog to require a valid selection only, preventing users from accepting the dialog if no selection is present.

setShowNoProjection

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

sharedPainter

showEvent

showNoCrsForLayerMessage

When called, the dialog will show a default "layer has no CRS set" message above the projection selector.

showNoProjection

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

tabletEvent

timerEvent

updateMicroFocus

wheelEvent

actionEvent(self, QActionEvent)
changeEvent(self, QEvent)
childEvent(self, QChildEvent)
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 CRS currently selected in the widget.

See also

setCrs()

Return type:

QgsCoordinateReferenceSystem

customEvent(self, QEvent)
destroy(self, destroyWindow: bool = True, destroySubWindows: bool = True)
disconnectNotify(self, QMetaMethod)
dragEnterEvent(self, QDragEnterEvent)
dragLeaveEvent(self, QDragLeaveEvent)
dragMoveEvent(self, QDragMoveEvent)
dropEvent(self, QDropEvent)
enterEvent(self, QEvent)
event(self, QEvent) bool
eventFilter(self, QObject, 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
hasValidSelection(self) bool

Returns True if the dialog has a valid CRS defined.

New in version 3.24.

Return type:

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]
paintEvent(self, QPaintEvent)
receivers(self, PYQT_SIGNAL) int
resizeEvent(self, QResizeEvent)
sender(self) QObject
senderSignalIndex(self) int
setCrs(self, crs: QgsCoordinateReferenceSystem)

Sets the initial crs to show within the dialog.

See also

crs()

Parameters:

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

setMessage(self, message: str)

Sets a message to show in the dialog.

Parameters:

message (str) –

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

Since QGIS 3.24, the description argument can be used to specify a detailed description which is shown when the option is selected.

New in version 3.16.

Parameters:
  • text (str) –

  • description (str = '') –

setOgcWmsCrsFilter(self, crsFilter: Iterable[str])

filters this dialog by the given CRSs

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

Parameters:

crsFilter (Iterable[str]) – a list of OGC Coordinate Reference Systems to filter the list of projections 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.

setRequireValidSelection(self)

Sets the dialog to require a valid selection only, preventing users from accepting the dialog if no selection is present.

New in version 3.18.

setShowNoProjection(self, show: bool)

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

Parameters:

show (bool) –

sharedPainter(self) QPainter
showEvent(self, QShowEvent)
showNoCrsForLayerMessage(self)

When called, the dialog will show a default “layer has no CRS set” message above the projection selector.

See also

setMessage()

New in version 3.16.

showNoProjection(self) bool

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

Return type:

bool

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