QGIS API Documentation  3.37.0-Master (a5b4d9743e8)
Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
QgsProjectionSelectionWidget Class Reference

A widget for selecting a projection. More...

#include <qgsprojectionselectionwidget.h>

Inheritance diagram for QgsProjectionSelectionWidget:
Inheritance graph
[legend]

Public Types

enum  CrsOption {
  Invalid = 1 << 0 , LayerCrs = 1 << 1 , ProjectCrs = 1 << 2 , CurrentCrs = 1 << 3 ,
  DefaultCrs = 1 << 4 , RecentCrs = 1 << 5 , CrsNotSet = 1 << 6
}
 Predefined CRS options shown in widget. More...
 
typedef QFlags< CrsOptionCrsOptions
 Flags for predefined CRS options shown in widget. More...
 

Public Slots

void selectCrs ()
 Opens the dialog for selecting a new CRS. More...
 
void setCrs (const QgsCoordinateReferenceSystem &crs)
 Sets the current CRS for the widget. More...
 
void setLayerCrs (const QgsCoordinateReferenceSystem &crs)
 Sets the layer CRS for the widget. More...
 

Signals

void cleared ()
 Emitted when the not set option is selected. More...
 
void crsChanged (const QgsCoordinateReferenceSystem &)
 Emitted when the selected CRS is changed. More...
 

Public Member Functions

 QgsProjectionSelectionWidget (QWidget *parent=nullptr, QgsCoordinateReferenceSystemProxyModel::Filters filters=QgsCoordinateReferenceSystemProxyModel::FilterHorizontal|QgsCoordinateReferenceSystemProxyModel::FilterCompound)
 Constructor for QgsProjectionSelectionWidget, with the specified parent widget. More...
 
QgsCoordinateReferenceSystem crs () const
 Returns the currently selected CRS for the widget. More...
 
QString dialogTitle () const
 Returns the title for the CRS selector dialog window. More...
 
QgsCoordinateReferenceSystemProxyModel::Filters filters () const
 Returns the filters set on the available CRS. More...
 
bool optionVisible (CrsOption option) const
 Returns whether the specified CRS option is visible in the widget. More...
 
void setDialogTitle (const QString &title)
 Sets the title for the CRS selector dialog window. More...
 
void setFilter (const QList< QgsCoordinateReferenceSystem > &crses)
 Sets a filtered list of CRSes to show in the widget. More...
 
void setFilters (QgsCoordinateReferenceSystemProxyModel::Filters filters)
 Sets filters for the available CRS. More...
 
void setMessage (const QString &text)
 Sets a message to show in the dialog. More...
 
void setNotSetText (const QString &text)
 Sets the text to show for the not set option. More...
 
void setOptionVisible (CrsOption option, bool visible)
 Sets whether a predefined CRS option should be shown in the widget. More...
 
void setShowAccuracyWarnings (bool show)
 Sets whether the widget will show warnings to users when they select a CRS which has low accuracy. More...
 
void setSourceEnsemble (const QString &ensemble)
 Sets the original source ensemble datum name. More...
 
bool showAccuracyWarnings () const
 Returns true if the widget will show a warning to users when they select a CRS which has low accuracy. More...
 
QString sourceEnsemble () const
 Returns the original source ensemble datum name. More...
 

Static Public Member Functions

static QString crsOptionText (const QgsCoordinateReferenceSystem &crs)
 Returns display text for the specified crs. More...
 

Protected Member Functions

void dragEnterEvent (QDragEnterEvent *event) override
 
void dragLeaveEvent (QDragLeaveEvent *event) override
 
void dropEvent (QDropEvent *event) override
 

Detailed Description

A widget for selecting a projection.

Definition at line 45 of file qgsprojectionselectionwidget.h.

Member Typedef Documentation

◆ CrsOptions

Flags for predefined CRS options shown in widget.

Since
QGIS 3.36

Definition at line 68 of file qgsprojectionselectionwidget.h.

Member Enumeration Documentation

◆ CrsOption

Predefined CRS options shown in widget.

Enumerator
Invalid 

Invalid option, since QGIS 3.36.

LayerCrs 

Optional layer CRS.

ProjectCrs 

Current project CRS (if OTF reprojection enabled)

CurrentCrs 

Current user selected CRS.

DefaultCrs 

Global default QGIS CRS.

RecentCrs 

Recently used CRS.

CrsNotSet 

Not set (hidden by default)

Definition at line 53 of file qgsprojectionselectionwidget.h.

Constructor & Destructor Documentation

◆ QgsProjectionSelectionWidget()

PRIVATE QgsProjectionSelectionWidget::QgsProjectionSelectionWidget ( QWidget *  parent = nullptr,
QgsCoordinateReferenceSystemProxyModel::Filters  filters = QgsCoordinateReferenceSystemProxyModel::FilterHorizontal | QgsCoordinateReferenceSystemProxyModel::FilterCompound 
)
explicit

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.

Definition at line 407 of file qgsprojectionselectionwidget.cpp.

Member Function Documentation

◆ cleared

void QgsProjectionSelectionWidget::cleared ( )
signal

Emitted when the not set option is selected.

◆ crs()

QgsCoordinateReferenceSystem QgsProjectionSelectionWidget::crs ( ) const

Returns the currently selected CRS for the widget.

Returns
current CRS

Definition at line 458 of file qgsprojectionselectionwidget.cpp.

◆ crsChanged

void QgsProjectionSelectionWidget::crsChanged ( const QgsCoordinateReferenceSystem )
signal

Emitted when the selected CRS is changed.

◆ crsOptionText()

QString QgsProjectionSelectionWidget::crsOptionText ( const QgsCoordinateReferenceSystem crs)
static

Returns display text for the specified crs.

Note
Not available in Python bindings
Since
QGIS 3.8

Definition at line 845 of file qgsprojectionselectionwidget.cpp.

◆ dialogTitle()

QString QgsProjectionSelectionWidget::dialogTitle ( ) const

Returns the title for the CRS selector dialog window.

See also
setDialogTitle()
Since
QGIS 3.24

Definition at line 676 of file qgsprojectionselectionwidget.cpp.

◆ dragEnterEvent()

void QgsProjectionSelectionWidget::dragEnterEvent ( QDragEnterEvent *  event)
overrideprotected

Definition at line 604 of file qgsprojectionselectionwidget.cpp.

◆ dragLeaveEvent()

void QgsProjectionSelectionWidget::dragLeaveEvent ( QDragLeaveEvent *  event)
overrideprotected

Definition at line 626 of file qgsprojectionselectionwidget.cpp.

◆ dropEvent()

void QgsProjectionSelectionWidget::dropEvent ( QDropEvent *  event)
overrideprotected

Definition at line 640 of file qgsprojectionselectionwidget.cpp.

◆ filters()

QgsCoordinateReferenceSystemProxyModel::Filters QgsProjectionSelectionWidget::filters ( ) const

Returns the filters set on the available CRS.

See also
setFilters()
Since
QGIS 3.36

Definition at line 686 of file qgsprojectionselectionwidget.cpp.

◆ optionVisible()

bool QgsProjectionSelectionWidget::optionVisible ( QgsProjectionSelectionWidget::CrsOption  option) const

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

See also
setOptionVisible()

Definition at line 511 of file qgsprojectionselectionwidget.cpp.

◆ selectCrs

void QgsProjectionSelectionWidget::selectCrs ( )
slot

Opens the dialog for selecting a new CRS.

Definition at line 517 of file qgsprojectionselectionwidget.cpp.

◆ setCrs

void QgsProjectionSelectionWidget::setCrs ( const QgsCoordinateReferenceSystem crs)
slot

Sets the current CRS for the widget.

Parameters
crsnew CRS

Definition at line 805 of file qgsprojectionselectionwidget.cpp.

◆ setDialogTitle()

void QgsProjectionSelectionWidget::setDialogTitle ( const QString &  title)

Sets the title for the CRS selector dialog window.

See also
dialogTitle()
Since
QGIS 3.24

Definition at line 671 of file qgsprojectionselectionwidget.cpp.

◆ setFilter()

void QgsProjectionSelectionWidget::setFilter ( const QList< QgsCoordinateReferenceSystem > &  crses)

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

Since
QGIS 3.28

Definition at line 681 of file qgsprojectionselectionwidget.cpp.

◆ setFilters()

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

Sets filters for the available CRS.

See also
filters()
Since
QGIS 3.36

Definition at line 691 of file qgsprojectionselectionwidget.cpp.

◆ setLayerCrs

void QgsProjectionSelectionWidget::setLayerCrs ( const QgsCoordinateReferenceSystem crs)
slot

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
crslayer CRS

Definition at line 840 of file qgsprojectionselectionwidget.cpp.

◆ setMessage()

void QgsProjectionSelectionWidget::setMessage ( const QString &  text)

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

Definition at line 506 of file qgsprojectionselectionwidget.cpp.

◆ setNotSetText()

void QgsProjectionSelectionWidget::setNotSetText ( const QString &  text)

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

Definition at line 501 of file qgsprojectionselectionwidget.cpp.

◆ setOptionVisible()

void QgsProjectionSelectionWidget::setOptionVisible ( const QgsProjectionSelectionWidget::CrsOption  option,
bool  visible 
)

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

Parameters
optionCRS option to show/hide
visiblewhether the option should be shown
See also
optionVisible()

Definition at line 463 of file qgsprojectionselectionwidget.cpp.

◆ setShowAccuracyWarnings()

void QgsProjectionSelectionWidget::setShowAccuracyWarnings ( bool  show)

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

See also
showAccuracyWarnings()
Since
QGIS 3.20

Definition at line 712 of file qgsprojectionselectionwidget.cpp.

◆ setSourceEnsemble()

void QgsProjectionSelectionWidget::setSourceEnsemble ( const QString &  ensemble)

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()
Since
QGIS 3.20

Definition at line 698 of file qgsprojectionselectionwidget.cpp.

◆ showAccuracyWarnings()

bool QgsProjectionSelectionWidget::showAccuracyWarnings ( ) const

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

See also
setShowAccuracyWarnings()
Since
QGIS 3.20

Definition at line 707 of file qgsprojectionselectionwidget.cpp.

◆ sourceEnsemble()

QString QgsProjectionSelectionWidget::sourceEnsemble ( ) const

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.

See also
setSourceEnsemble()
Since
QGIS 3.20

Definition at line 666 of file qgsprojectionselectionwidget.cpp.


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