QgsDoubleSpinBox class
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value.
Contents
The clear value can be either the minimum or the maiximum value of the spin box or a custom value. This value can then be handled by a special value text.
Public types
- enum ClearValueMode { MinimumValue, MaximumValue, CustomValue }
- Behavior when widget is cleared.
Constructors, destructors, conversion operators
- QgsDoubleSpinBox(QWidget* parent = nullptr) explicit
- Constructor for QgsDoubleSpinBox.
Public functions
- void clear() override
- Sets the current value to the value defined by the clear value.
- auto clearValue() const -> double
- Returns the value used when clear() is called.
- auto expressionsEnabled() const -> bool
- Returns whether the widget will allow entry of simple expressions, which are evaluated and then discarded.
- void setClearValue(double customValue, const QString& clearValueText = QString())
- Defines the clear value as a custom value and will automatically set the clear value mode to CustomValue.
- void setClearValueMode(ClearValueMode mode, const QString& clearValueText = QString())
- Defines if the clear value should be the minimum or maximum values of the widget or a custom value.
- void setExpressionsEnabled(bool enabled)
- Sets if the widget will allow entry of simple expressions, which are evaluated and then discarded.
- void setLineEditAlignment(Qt::Alignment alignment)
- Set alignment in the embedded line edit widget.
- void setShowClearButton(bool showClearButton)
- Sets whether the widget will show a clear button.
- void setSpecialValueText(const QString& txt)
- Set the special-value text to be txt If set, the spin box will display this text instead of a numeric value whenever the current value is equal to minimum().
- auto showClearButton() const -> bool
- Returns whether the widget is showing a clear button.
Enum documentation
enum QgsDoubleSpinBox:: ClearValueMode
Behavior when widget is cleared.
| Enumerators | |
|---|---|
| MinimumValue |
Reset value to minimum() |
| MaximumValue |
Reset value to maximum() |
| CustomValue |
Reset value to custom value (see setClearValue() ) |
Function documentation
QgsDoubleSpinBox:: QgsDoubleSpinBox(QWidget* parent = nullptr) explicit
Constructor for QgsDoubleSpinBox.
| Parameters | |
|---|---|
| parent | parent widget |
double QgsDoubleSpinBox:: clearValue() const
Returns the value used when clear() is called.
bool QgsDoubleSpinBox:: expressionsEnabled() const
Returns whether the widget will allow entry of simple expressions, which are evaluated and then discarded.
| Returns | true if spin box allows expression entry |
|---|
void QgsDoubleSpinBox:: setClearValue(double customValue,
const QString& clearValueText = QString())
Defines the clear value as a custom value and will automatically set the clear value mode to CustomValue.
| Parameters | |
|---|---|
| customValue | defines the numerical value used as the clear value |
| clearValueText | is the text displayed when the spin box is at the clear value. If not specified, no special value text is used. |
void QgsDoubleSpinBox:: setClearValueMode(ClearValueMode mode,
const QString& clearValueText = QString())
Defines if the clear value should be the minimum or maximum values of the widget or a custom value.
| Parameters | |
|---|---|
| mode | mode to user for clear value |
| clearValueText | is the text displayed when the spin box is at the clear value. If not specified, no special value text is used. |
void QgsDoubleSpinBox:: setExpressionsEnabled(bool enabled)
Sets if the widget will allow entry of simple expressions, which are evaluated and then discarded.
| Parameters | |
|---|---|
| enabled | set to true to allow expression entry |
void QgsDoubleSpinBox:: setLineEditAlignment(Qt::Alignment alignment)
Set alignment in the embedded line edit widget.
| Parameters | |
|---|---|
| alignment | |
void QgsDoubleSpinBox:: setShowClearButton(bool showClearButton)
Sets whether the widget will show a clear button.
| Parameters | |
|---|---|
| showClearButton | set to true to show the clear button, or false to hide it |
The clear button allows users to reset the widget to a default or empty state.
void QgsDoubleSpinBox:: setSpecialValueText(const QString& txt)
Set the special-value text to be txt If set, the spin box will display this text instead of a numeric value whenever the current value is equal to minimum().
Typical use is to indicate that this choice has a special (default) meaning.
bool QgsDoubleSpinBox:: showClearButton() const
Returns whether the widget is showing a clear button.