SHAPER
9.12.0
|
An extension and customization of QDoubleSpinBox class. More...
Public Member Functions | |
ModuleBase_DoubleSpinBox (QWidget *theParent=0, int thePrecision=-12) | |
Constructor. More... | |
virtual | ~ModuleBase_DoubleSpinBox () |
Destructor. More... | |
bool | isCleared () const |
Returns true if the control is clear. More... | |
virtual void | setCleared (const bool) |
Set control clear. More... | |
int | getPrecision () const |
Returns current precision. More... | |
void | setPrecision (const int) |
Set precision. More... | |
virtual void | stepBy (int) |
Set step. More... | |
virtual double | valueFromText (const QString &) const |
Converts value from string to double. More... | |
virtual QString | textFromValue (double) const |
Convert value from double to string. More... | |
virtual QValidator::State | validate (QString &, int &) const |
Validate current value. More... | |
void | setValueEnabled (const bool &theEnable) |
Imitation of disable control value. More... | |
Protected Slots | |
virtual void | onTextChanged (const QString &) |
Called on text changed. More... | |
Protected Member Functions | |
QString | removeTrailingZeroes (const QString &) const |
Removes extra trailing zero symbols. More... | |
An extension and customization of QDoubleSpinBox class.
Enhanced version of the Qt's double spin box.
The ModuleBase_DoubleSpinBox 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 widget 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 ModuleBase_DoubleSpinBox class. "decimals" is still used for proper size hint calculation and for rounding minimum and maximum bounds of the spin box range.
|
explicit |
Constructor.
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.
theParent | parent object |
thePrecision | precision of values input |
|
virtual |
Destructor.
bool ModuleBase_DoubleSpinBox::isCleared | ( | ) | const |
Returns true if the control is clear.
Check if spin box is in the "cleared" state.
true
if spin box is cleared
|
virtual |
Set control clear.
Change "cleared" status of the spin box.
on | new "cleared" status |
int ModuleBase_DoubleSpinBox::getPrecision | ( | ) | const |
Returns current precision.
Get precision value of the spin box.
void ModuleBase_DoubleSpinBox::setPrecision | ( | const int | prec | ) |
Set precision.
Set precision of the spin box.
If precision value is less than 0, the 'g' format is used for value output, otherwise 'f' format is used.
prec | new precision value. |
|
virtual |
Set step.
Perform steps increment/decrement steps.
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 |
|
virtual |
Converts value from string to double.
Interpret text entered by the user as a value.
text | text entered by the user |
|
virtual |
Convert value from double to string.
This function is used by the spin box whenever it needs to display the given value.
val | spin box value |
|
virtual |
Validate current value.
This function is used to determine whether input is valid.
str | currently entered value |
pos | cursor position in the string |
void ModuleBase_DoubleSpinBox::setValueEnabled | ( | const bool & | theEnable | ) |
Imitation of disable control value.
If theEnable is false, the control becomes read only and base color is disabled.
|
protectedvirtualslot |
Called on text changed.
Called when user enters the text in the spin box.
|
protected |
Removes extra trailing zero symbols.
Return source string with removed leading and trailing zeros.
src | source string |