Enhanced version of the Qt's double spin box. More...
#include <QtxDoubleSpinBox.h>
Public Member Functions | |
QtxDoubleSpinBox (QWidget *=0) | |
Constructor. More... | |
QtxDoubleSpinBox (double, double, double=1, QWidget *=0) | |
Constructor. More... | |
QtxDoubleSpinBox (double, double, double, int, int, QWidget *=0) | |
Constructor. More... | |
virtual | ~QtxDoubleSpinBox () |
Destructor. More... | |
bool | isCleared () const |
Check if spin box is in the "cleared" state. More... | |
virtual void | setCleared (const bool) |
Change "cleared" status of the spin box. More... | |
int | getPrecision () const |
Get precision value of the spin box. More... | |
void | setPrecision (const int) |
Set precision of the spin box. More... | |
virtual void | stepBy (int) |
Perform steps increment/decrement steps. More... | |
virtual double | valueFromText (const QString &) const |
Interpret text entered by the user as a value. More... | |
virtual QString | textFromValue (double) const |
This function is used by the spin box whenever it needs to display the given value. More... | |
virtual QValidator::State | validate (QString &, int &) const |
This function is used to determine whether input is valid. More... | |
Protected Slots | |
virtual void | onTextChanged (const QString &) |
Called when user enters the text in the spin box. More... | |
Protected Member Functions | |
QString | removeTrailingZeroes (const QString &) const |
Return source string with removed leading and trailing zeros. More... | |
Private Attributes | |
bool | myCleared |
int | myPrecision |
The QtxDoubleSpinBox class represents the widget for entering the floating point values. In addition to the functionality provided by QDoubleSpinBox, this class supports "cleared" state - this is the state corresponding to "None" (or empty) entered value.
To set "cleared" state use setCleared() method. To check if the spin box stores "cleared" state, use isCleared() method. For example:
Another useful feature is possibility to use scientific notation (e.g. 1.234e+18) for the widegt text. To enable this, negative precision should be specified either through a constructor or using setPrecision() method.
Note that "decimals" property of QDoubleSpinBox is almost completely substituted by "myPrecision" field of QtxDoubleSpinBox class. "decimals" is still used for proper size hint calculation and for rounding minimum and maximum bounds of the spin box range.
QtxDoubleSpinBox::QtxDoubleSpinBox | ( | QWidget * | parent = 0 | ) |
Constructs a spin box with 0.0 as minimum value and 99.99 as maximum value, a step value of 1.0 and a precision of 2 decimal places. The value is initially set to 0.00.
parent | parent object |
References myPrecision, and onTextChanged().
QtxDoubleSpinBox::QtxDoubleSpinBox | ( | double | min, |
double | max, | ||
double | step = 1 , |
||
QWidget * | parent = 0 |
||
) |
Constructs a spin box with specified minimum, maximum and step value. The precision is set to 2 decimal places. The value is initially set to the minimum value.
min | spin box minimum possible value |
max | spin box maximum possible value |
step | spin box increment/decrement value |
parent | parent object |
References myPrecision, and onTextChanged().
QtxDoubleSpinBox::QtxDoubleSpinBox | ( | double | min, |
double | max, | ||
double | step, | ||
int | prec, | ||
int | dec, | ||
QWidget * | parent = 0 |
||
) |
Constructs a spin box with specified minimum, maximum and step value. The precision is set to <prec> decimal places. The value is initially set to the minimum value.
min | spin box minimum possible value |
max | spin box maximum possible value |
step | spin box increment/decrement value |
prec | non-negative values means the number of digits after the decimal point, negative value means the maximum number of significant digits for the scientific notation |
dec | number of digits after the decimal point passed to base Qt class (used for correct control sizing only!) |
parent | parent object |
References onTextChanged().
|
virtual |
int QtxDoubleSpinBox::getPrecision | ( | ) | const |
bool QtxDoubleSpinBox::isCleared | ( | ) | const |
|
protectedvirtualslot |
txt | current spin box text (not used) |
References myCleared.
|
protected |
str | source string |
|
virtual |
void QtxDoubleSpinBox::setPrecision | ( | const int | prec | ) |
If precision value is less than 0, the 'g' format is used for value output, otherwise 'f' format is used.
prec | new precision value. |
References myPrecision.
|
virtual |
The steps value can be any integer number. If it is > 0, the value incrementing is done, otherwise value is decremented steps times.
steps | number of increment/decrement steps |
Reimplemented in SalomeApp_DoubleSpinBox.
References myCleared, and PSEUDO_ZERO.
|
virtual |
val | spin box value |
Reimplemented in SalomeApp_DoubleSpinBox.
References myPrecision, removeTrailingZeroes(), and s.
|
virtual |
str | currently entered value |
pos | cursor position in the string |
Reimplemented in SalomeApp_DoubleSpinBox.
References myPrecision.
|
virtual |
text | text entered by the user |
Reimplemented in SalomeApp_DoubleSpinBox.
References myPrecision.
|
private |
|
private |