QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
Signals | Public Member Functions | List of all members
QgsUnitSelectionWidget Class Reference

A widget displaying a combobox allowing the user to choose between various display units, such as millimeters or map units. More...

#include <qgsunitselectionwidget.h>

Inheritance diagram for QgsUnitSelectionWidget:
Inheritance graph
[legend]

Signals

void changed ()
 Emitted when the selected unit is changed, or the definition of the map unit scale is changed.
 

Public Member Functions

 QgsUnitSelectionWidget (QWidget *parent=nullptr)
 Constructor for QgsUnitSelectionWidget.
 
QgsMapUnitScale getMapUnitScale () const
 Returns the map unit scale.
 
int getUnit () const
 Gets the selected unit index.
 
void setMapCanvas (QgsMapCanvas *canvas)
 Sets the map canvas associated with the widget.
 
void setMapUnitScale (const QgsMapUnitScale &scale)
 Sets the map unit scale.
 
void setShowMapScaleButton (bool show)
 Sets whether the widget can show the map scale button when the Map Units option is selected.
 
void setUnit (int unitIndex)
 Sets the selected unit index.
 
void setUnit (Qgis::RenderUnit unit)
 Sets the selected unit.
 
void setUnits (const QgsUnitTypes::RenderUnitList &units)
 Sets the units which the user can choose from in the combobox.
 
void setUnits (const QStringList &units, int mapUnitIdx)
 Sets the units which the user can choose from in the combobox.
 
bool showMapScaleButton () const
 Returns true if the widget can show the map scale button when the Map Units option is selected.
 
Qgis::RenderUnit unit () const
 Returns the current predefined selected unit (if applicable).
 

Detailed Description

A widget displaying a combobox allowing the user to choose between various display units, such as millimeters or map units.

If the user chooses map units, a button appears allowing adjustment of minimum and maximum scaling.

See also
QgsMapUnitScaleWidget
QgsMapUnitScaleDialog

Definition at line 165 of file qgsunitselectionwidget.h.

Constructor & Destructor Documentation

◆ QgsUnitSelectionWidget()

QgsUnitSelectionWidget::QgsUnitSelectionWidget ( QWidget *  parent = nullptr)

Constructor for QgsUnitSelectionWidget.

Parameters
parentparent widget

Definition at line 127 of file qgsunitselectionwidget.cpp.

Member Function Documentation

◆ changed

void QgsUnitSelectionWidget::changed ( )
signal

Emitted when the selected unit is changed, or the definition of the map unit scale is changed.

◆ getMapUnitScale()

QgsMapUnitScale QgsUnitSelectionWidget::getMapUnitScale ( ) const
inline

Returns the map unit scale.

Definition at line 213 of file qgsunitselectionwidget.h.

◆ getUnit()

int QgsUnitSelectionWidget::getUnit ( ) const
inline

Gets the selected unit index.

Definition at line 191 of file qgsunitselectionwidget.h.

◆ setMapCanvas()

void QgsUnitSelectionWidget::setMapCanvas ( QgsMapCanvas canvas)

Sets the map canvas associated with the widget.

This allows the widget to retrieve the current map scale from the canvas.

Parameters
canvasmap canvas

Definition at line 220 of file qgsunitselectionwidget.cpp.

◆ setMapUnitScale()

void QgsUnitSelectionWidget::setMapUnitScale ( const QgsMapUnitScale scale)
inline

Sets the map unit scale.

Definition at line 216 of file qgsunitselectionwidget.h.

◆ setShowMapScaleButton()

void QgsUnitSelectionWidget::setShowMapScaleButton ( bool  show)

Sets whether the widget can show the map scale button when the Map Units option is selected.

See also
showMapScaleButton()
Since
QGIS 3.22

Definition at line 275 of file qgsunitselectionwidget.cpp.

◆ setUnit() [1/2]

void QgsUnitSelectionWidget::setUnit ( int  unitIndex)

Sets the selected unit index.

Parameters
unitIndexindex of unit to set as current
Note
available in Python bindings as setUnitIndex

Definition at line 207 of file qgsunitselectionwidget.cpp.

◆ setUnit() [2/2]

void QgsUnitSelectionWidget::setUnit ( Qgis::RenderUnit  unit)

Sets the selected unit.

Parameters
unitpredefined unit to set as current

Definition at line 214 of file qgsunitselectionwidget.cpp.

◆ setUnits() [1/2]

void QgsUnitSelectionWidget::setUnits ( const QgsUnitTypes::RenderUnitList units)

Sets the units which the user can choose from in the combobox.

Clears any existing units.

Parameters
unitslist of valid units

Definition at line 153 of file qgsunitselectionwidget.cpp.

◆ setUnits() [2/2]

void QgsUnitSelectionWidget::setUnits ( const QStringList &  units,
int  mapUnitIdx 
)

Sets the units which the user can choose from in the combobox.

Parameters
unitslist of strings for custom units to display in the widget
mapUnitIdxspecifies which entry corresponds to the map units, or -1 if none

Definition at line 145 of file qgsunitselectionwidget.cpp.

◆ showMapScaleButton()

bool QgsUnitSelectionWidget::showMapScaleButton ( ) const

Returns true if the widget can show the map scale button when the Map Units option is selected.

See also
setShowMapScaleButton()
Since
QGIS 3.22

Definition at line 270 of file qgsunitselectionwidget.cpp.

◆ unit()

Qgis::RenderUnit QgsUnitSelectionWidget::unit ( ) const

Returns the current predefined selected unit (if applicable).

Returns
selected output unit, or QgsUnitTypes::RenderUnknownUnit if the widget was populated with custom unit types

Definition at line 193 of file qgsunitselectionwidget.cpp.


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