QgsUnitSelectionWidget class
A widget displaying a combobox allowing the user to choose between various display units, such as millimeters or map unit.
Contents
If the user chooses map units, a button appears allowing adjustment of minimum and maximum scaling.
Constructors, destructors, conversion operators
- QgsUnitSelectionWidget(QWidget* parent = nullptr)
- Constructor for QgsUnitSelectionWidget.
Public functions
- auto getMapUnitScale() const -> QgsMapUnitScale
- Returns the map unit scale.
- auto getUnit() const -> int
- 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 setUnit(int unitIndex)
- Sets the selected unit index.
-
void setUnit(QgsUnitTypes::
RenderUnit unit) - Sets the selected unit.
- void setUnits(const QStringList& units, int mapUnitIdx)
- Sets the units which the user can choose from in the combobox.
-
void setUnits(const QgsUnitTypes::
RenderUnitList& units) - Sets the units which the user can choose from in the combobox.
-
auto unit() const -> QgsUnitTypes::
RenderUnit - Returns the current predefined selected unit (if applicable).
Function documentation
QgsUnitSelectionWidget:: QgsUnitSelectionWidget(QWidget* parent = nullptr)
Constructor for QgsUnitSelectionWidget.
| Parameters | |
|---|---|
| parent | parent widget |
void QgsUnitSelectionWidget:: setMapCanvas(QgsMapCanvas* canvas)
Sets the map canvas associated with the widget.
| Parameters | |
|---|---|
| canvas | map canvas |
This allows the widget to retrieve the current map scale from the canvas.
void QgsUnitSelectionWidget:: setUnit(int unitIndex)
Sets the selected unit index.
| Parameters | |
|---|---|
| unitIndex | index of unit to set as current |
void QgsUnitSelectionWidget:: setUnit(QgsUnitTypes:: RenderUnit unit)
Sets the selected unit.
| Parameters | |
|---|---|
| unit | predefined unit to set as current |
void QgsUnitSelectionWidget:: setUnits(const QStringList& units,
int mapUnitIdx)
Sets the units which the user can choose from in the combobox.
| Parameters | |
|---|---|
| units | list of strings for custom units to display in the widget |
| mapUnitIdx | specifies which entry corresponds to the map units, or -1 if none |
void QgsUnitSelectionWidget:: setUnits(const QgsUnitTypes:: RenderUnitList& units)
Sets the units which the user can choose from in the combobox.
| Parameters | |
|---|---|
| units | list of valid units |
Clears any existing units.
QgsUnitTypes:: RenderUnit QgsUnitSelectionWidget:: unit() const
Returns the current predefined selected unit (if applicable).
| Returns | selected output unit, or QgsUnitTypes:: |
|---|