16#ifndef QGSDOUBLESPINBOX_H
17#define QGSDOUBLESPINBOX_H
22#include <QDoubleSpinBox>
24class QgsSpinBoxLineEdit;
49 if ( qobject_cast<QgsDoubleSpinBox *>( sipCpp ) )
50 sipType = sipType_QgsDoubleSpinBox;
82 void setShowClearButton(
bool showClearButton );
95 void setExpressionsEnabled(
bool enabled );
105 void clear()
override;
113 void setClearValue(
double customValue,
const QString &clearValueText = QString() );
120 void setClearValueMode( ClearValueMode mode,
const QString &clearValueText = QString() );
126 double clearValue()
const;
135 bool isCleared()
const;
141 void setLineEditAlignment( Qt::Alignment alignment );
148 void setSpecialValueText(
const QString &txt );
150 double valueFromText(
const QString &text )
const override;
151 QValidator::State validate( QString &input,
int &pos )
const override;
152 void paintEvent( QPaintEvent *e )
override;
153 void stepBy(
int steps )
override;
163 int editingTimeoutInterval()
const;
176 void setEditingTimeoutInterval(
int timeout );
209 void wheelEvent( QWheelEvent *event )
override;
214 void timerEvent( QTimerEvent *event )
override;
217 void changed(
double value );
218 void onLastEditTimeout();
221 int frameWidth()
const;
222 bool shouldShowClearForValue(
double value )
const;
224 QgsSpinBoxLineEdit *mLineEdit =
nullptr;
226 bool mShowClearButton =
true;
228 double mCustomClearValue = 0.0;
230 bool mExpressionsEnabled =
true;
232 QTimer *mLastEditTimer =
nullptr;
233 double mLastEditTimeoutValue = std::numeric_limits<double>::quiet_NaN();
235 QString stripped(
const QString &originalText )
const;
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value.
void wheelEvent(QWheelEvent *event) override
void textEdited(const QString &text)
Emitted when the the value has been manually edited via line edit.
void editingTimeout(double value)
Emitted when either:
bool showClearButton() const
Returns whether the widget is showing a clear button.
void focusOutEvent(QFocusEvent *event) override
void changeEvent(QEvent *event) override
ClearValueMode
Behavior when widget is cleared.
@ MaximumValue
Reset value to maximum().
@ CustomValue
Reset value to custom value (see setClearValue() ).
@ MinimumValue
Reset value to minimum().
friend class TestQgsRangeWidgetWrapper
QgsDoubleSpinBox(QWidget *parent=nullptr)
Constructor for QgsDoubleSpinBox.
void setExpressionsEnabled(bool enabled)
Sets if 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 CustomVa...
void setShowClearButton(bool showClearButton)
Sets whether the widget will show a clear button.
void timerEvent(QTimerEvent *event) override
void returnPressed()
Emitted when the Return or Enter key is used in the line edit.
bool expressionsEnabled() const
Returns whether the widget will allow entry of simple expressions, which are evaluated and then disca...
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)