QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
Public Slots | Public Member Functions | List of all members
QgsProjectionSelectionDialog Class Reference

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

#include <qgsprojectionselectiondialog.h>

Inheritance diagram for QgsProjectionSelectionDialog:
Inheritance graph
[legend]

Public Slots

void setCrs (const QgsCoordinateReferenceSystem &crs)
 Sets the initial crs to show within the dialog.
 
void setOgcWmsCrsFilter (const QSet< QString > &crsFilter)
 filters this dialog by the given CRSs
 

Public Member Functions

 QgsProjectionSelectionDialog (QWidget *parent=nullptr, Qt::WindowFlags fl=QgsGuiUtils::ModalDialogFlags, QgsCoordinateReferenceSystemProxyModel::Filters filters=QgsCoordinateReferenceSystemProxyModel::FilterHorizontal|QgsCoordinateReferenceSystemProxyModel::FilterCompound)
 Constructor for QgsProjectionSelectionDialog.
 
QgsCoordinateReferenceSystem crs () const
 Returns the CRS currently selected in the widget.
 
QgsCoordinateReferenceSystemProxyModel::Filters filters () const
 Returns the filters set on the available CRS.
 
bool hasValidSelection () const
 Returns true if the dialog has a valid CRS defined.
 
void setFilters (QgsCoordinateReferenceSystemProxyModel::Filters filters)
 Sets filters for the available CRS.
 
void setMessage (const QString &message)
 Sets a message to show in the dialog.
 
void setNotSetText (const QString &text, const QString &description=QString())
 Sets the text to show for the not set option.
 
void setRequireValidSelection ()
 Sets the dialog to require a valid selection only, preventing users from accepting the dialog if no selection is present.
 
void setShowNoProjection (bool show)
 Sets whether a "no/invalid" projection option should be shown.
 
void showNoCrsForLayerMessage ()
 When called, the dialog will show a default "layer has no CRS set" message above the projection selector.
 
bool showNoProjection () const
 Returns whether the "no/invalid" projection option is shown.
 

Detailed Description

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:

mySelector = QgsProjectionSelectionDialog( iface.mainWindow() )
mySelector.setCrs( crs )
if mySelector.exec():
mCrs = mySelector.crs()
This class represents a coordinate reference system (CRS).
A generic dialog to prompt the user for a Coordinate Reference System.

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

Definition at line 190 of file qgsprojectionselectiondialog.h.

Constructor & Destructor Documentation

◆ QgsProjectionSelectionDialog()

QgsProjectionSelectionDialog::QgsProjectionSelectionDialog ( QWidget *  parent = nullptr,
Qt::WindowFlags  fl = QgsGuiUtils::ModalDialogFlags,
QgsCoordinateReferenceSystemProxyModel::Filters  filters = 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.

Definition at line 263 of file qgsprojectionselectiondialog.cpp.

Member Function Documentation

◆ crs()

QgsCoordinateReferenceSystem QgsProjectionSelectionDialog::crs ( ) const

Returns the CRS currently selected in the widget.

See also
setCrs()

Definition at line 341 of file qgsprojectionselectiondialog.cpp.

◆ filters()

QgsCoordinateReferenceSystemProxyModel::Filters QgsProjectionSelectionDialog::filters ( ) const

Returns the filters set on the available CRS.

See also
setFilters()
Since
QGIS 3.36

Definition at line 331 of file qgsprojectionselectiondialog.cpp.

◆ hasValidSelection()

bool QgsProjectionSelectionDialog::hasValidSelection ( ) const

Returns true if the dialog has a valid CRS defined.

Since
QGIS 3.24

Definition at line 326 of file qgsprojectionselectiondialog.cpp.

◆ setCrs

void QgsProjectionSelectionDialog::setCrs ( const QgsCoordinateReferenceSystem crs)
slot

Sets the initial crs to show within the dialog.

See also
crs()

Definition at line 346 of file qgsprojectionselectiondialog.cpp.

◆ setFilters()

void QgsProjectionSelectionDialog::setFilters ( QgsCoordinateReferenceSystemProxyModel::Filters  filters)

Sets filters for the available CRS.

See also
filters()
Since
QGIS 3.36

Definition at line 336 of file qgsprojectionselectiondialog.cpp.

◆ setMessage()

void QgsProjectionSelectionDialog::setMessage ( const QString &  message)

Sets a message to show in the dialog.

See also
showNoCrsForLayerMessage()

Definition at line 287 of file qgsprojectionselectiondialog.cpp.

◆ setNotSetText()

void QgsProjectionSelectionDialog::setNotSetText ( const QString &  text,
const QString &  description = QString() 
)

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.

Since
QGIS 3.16

Definition at line 310 of file qgsprojectionselectiondialog.cpp.

◆ setOgcWmsCrsFilter

void QgsProjectionSelectionDialog::setOgcWmsCrsFilter ( const QSet< QString > &  crsFilter)
slot

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

Definition at line 354 of file qgsprojectionselectiondialog.cpp.

◆ setRequireValidSelection()

void QgsProjectionSelectionDialog::setRequireValidSelection ( )

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

Since
QGIS 3.18

Definition at line 315 of file qgsprojectionselectiondialog.cpp.

◆ setShowNoProjection()

void QgsProjectionSelectionDialog::setShowNoProjection ( bool  show)

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

If this option is selected, calling crs() will return an invalid QgsCoordinateReferenceSystem.

See also
showNoProjection()

Definition at line 300 of file qgsprojectionselectiondialog.cpp.

◆ showNoCrsForLayerMessage()

void QgsProjectionSelectionDialog::showNoCrsForLayerMessage ( )

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

See also
setMessage()
Since
QGIS 3.16

Definition at line 292 of file qgsprojectionselectiondialog.cpp.

◆ showNoProjection()

bool QgsProjectionSelectionDialog::showNoProjection ( ) const

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

If this option is selected, calling crs() will return an invalid QgsCoordinateReferenceSystem.

See also
setShowNoProjection()

Definition at line 305 of file qgsprojectionselectiondialog.cpp.


The documentation for this class was generated from the following files: