QGIS API Documentation
3.20.0-Odense (decaadbb31)
|
A combobox which lets the user select map scale from predefined list and highlights nearest to current scale value. More...
#include <qgsscalewidget.h>
Public Slots | |
void | setMinScale (double scale) |
Set the minimum allowed scale. More... | |
void | setNull () |
Sets the widget to the null value. More... | |
void | setScale (double scale) |
Set the selected scale from a double. More... | |
void | setScaleFromCanvas () |
Assigns the current scale from the map canvas, if set. More... | |
void | updateScales (const QStringList &scales=QStringList()) |
Sets the list of predefined scales to show in the combobox. More... | |
Signals | |
void | scaleChanged (double scale) |
Emitted when user has finished editing/selecting a new scale. More... | |
Public Member Functions | |
QgsScaleWidget (QWidget *parent=nullptr) | |
QgsScaleWidget creates a combobox which lets the user select map scale from predefined list and highlights nearest to current scale value. More... | |
bool | allowNull () const |
Returns true if the widget can be set to a NULL value. More... | |
bool | isNull () const |
Returns true if the widget is currently set to a "null" value. More... | |
double | minScale () const |
Returns the minimum scale, or 0 if no minimum scale set. More... | |
double | scale () const |
Returns the selected scale as a double. More... | |
QString | scaleString () const |
Returns the selected scale as a string, e.g. More... | |
void | setAllowNull (bool allowNull) |
Sets whether the scale widget can be set to a NULL value. More... | |
void | setMapCanvas (QgsMapCanvas *canvas) |
Set the map canvas associated to the current button. More... | |
bool | setScaleString (const QString &string) |
Set the selected scale from a string, e.g. More... | |
void | setShowCurrentScaleButton (bool showCurrentScaleButton) |
Sets whether to show a button to set the scale to the current scale of the map canvas next to the combobox. More... | |
bool | showCurrentScaleButton () |
Returns whether a button to set the scale from map canvas is shown or not. More... | |
Static Public Member Functions | |
static double | toDouble (const QString &scaleString, bool *ok=nullptr) |
Helper function to convert a scale string to double. More... | |
static QString | toString (double scale) |
Helper function to convert a scale double to scale string. More... | |
Properties | |
bool | minScale |
bool | scale |
bool | showCurrentScaleButton |
A combobox which lets the user select map scale from predefined list and highlights nearest to current scale value.
Definition at line 34 of file qgsscalewidget.h.
|
explicit |
QgsScaleWidget creates a combobox which lets the user select map scale from predefined list and highlights nearest to current scale value.
Definition at line 28 of file qgsscalewidget.cpp.
bool QgsScaleWidget::allowNull | ( | ) | const |
Returns true
if the widget can be set to a NULL value.
Definition at line 76 of file qgsscalewidget.cpp.
bool QgsScaleWidget::isNull | ( | ) | const |
Returns true
if the widget is currently set to a "null" value.
Definition at line 66 of file qgsscalewidget.cpp.
|
inline |
Returns the minimum scale, or 0 if no minimum scale set.
The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map. Any scale lower than the minimum scale will automatically be converted to the minimum scale. Except for 0 which is always allowed.
Definition at line 102 of file qgsscalewidget.h.
|
inline |
Returns the selected scale as a double.
The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
Definition at line 85 of file qgsscalewidget.h.
|
signal |
Emitted when user has finished editing/selecting a new scale.
The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
|
inline |
Returns the selected scale as a string, e.g.
"1:150".
Definition at line 72 of file qgsscalewidget.h.
void QgsScaleWidget::setAllowNull | ( | bool | allowNull | ) |
Sets whether the scale widget can be set to a NULL value.
Definition at line 71 of file qgsscalewidget.cpp.
void QgsScaleWidget::setMapCanvas | ( | QgsMapCanvas * | canvas | ) |
Set the map canvas associated to the current button.
Definition at line 60 of file qgsscalewidget.cpp.
|
inlineslot |
Set the minimum allowed scale.
Set to 0 to disable the minimum scale. The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map. Any scale lower than the minimum scale will automatically be converted to the minimum scale. Except for 0 which is always allowed.
Definition at line 166 of file qgsscalewidget.h.
|
slot |
Sets the widget to the null value.
This only has an effect if allowNull() is true
.
Definition at line 89 of file qgsscalewidget.cpp.
|
slot |
Set the selected scale from a double.
The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
Definition at line 94 of file qgsscalewidget.cpp.
|
slot |
Assigns the current scale from the map canvas, if set.
Definition at line 81 of file qgsscalewidget.cpp.
|
inline |
Set the selected scale from a string, e.g.
"1:150".
Definition at line 78 of file qgsscalewidget.h.
void QgsScaleWidget::setShowCurrentScaleButton | ( | bool | showCurrentScaleButton | ) |
Sets whether to show a button to set the scale to the current scale of the map canvas next to the combobox.
Definition at line 54 of file qgsscalewidget.cpp.
|
inline |
Returns whether a button to set the scale from map canvas is shown or not.
Definition at line 61 of file qgsscalewidget.h.
|
inlinestatic |
Helper function to convert a scale string to double.
The returned value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map. If specified, ok will be set to true
if the string was successfully interpreted as a scale.
Definition at line 119 of file qgsscalewidget.h.
|
inlinestatic |
Helper function to convert a scale double to scale string.
The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
The returned string will be rounded (e.g. 1:1000, not 1:1000.345).
Definition at line 111 of file qgsscalewidget.h.
|
inlineslot |
Sets the list of predefined scales to show in the combobox.
List elements are expected to be valid scale strings, such as "1:1000000".
Definition at line 152 of file qgsscalewidget.h.
|
readwrite |
Definition at line 1 of file qgsscalewidget.h.
|
readwrite |
Definition at line 1 of file qgsscalewidget.h.
|
readwrite |
Definition at line 1 of file qgsscalewidget.h.