Main Page Modules Namespace List Class Hierarchy Compound List File List Namespace Members Compound Members Related Pages
KDoubleSpinBox Class Reference
A spin box for fractional numbers.
More...
#include <knuminput.h>
List of all members.
|
Public Slots |
| virtual void | setValue (double value) |
Signals |
| void | valueChanged (double value) |
Public Methods |
| | KDoubleSpinBox (QWidget *parent=0, const char *name=0) |
| | KDoubleSpinBox (double lower, double upper, double step, double value, int precision=2, QWidget *parent=0, const char *name=0) |
| bool | acceptLocalizedNumbers () const |
| virtual void | setAcceptLocalizedNumbers (bool accept) |
| void | setRange (double lower, double upper, double step=0.01, int precision=2) |
| int | precision () const |
| void | setPrecision (int precision) |
| virtual void | setPrecision (int precision, bool force) |
| double | value () const |
| double | minValue () const |
| void | setMinValue (double value) |
| double | maxValue () const |
| void | setMaxValue (double value) |
| double | lineStep () const |
| void | setLineStep (double step) |
| void | setValidator (const QValidator *) |
Detailed Description
A spin box for fractional numbers.
This class provides a spin box for fractional numbers.
@sect Parameters
There are a number of interdependent parameters whose relation to each other you need to understand in order to make successful use of the spin box.
- precision: The number of decimals after the decimal point.
- maxValue/minValue: upper and lower bound of the valid range
- lineStep: the size of the step that is taken when the user hits the up or down buttons
Since we work with fixed-point numbers internally, the maximum precision is a function of the valid range and vice versa. More precisely, the following relations hold:
max( abs(minValue()), abs(maxValue() ) <= INT_MAX/10^precision
maxPrecision = floor( log10( INT_MAX/max(abs(minValue()),abs(maxValue())) ) )
Since the value, bounds and step are rounded to the current precision, you may experience that the order of setting above parameters matters. E.g. the following are not equivalent (try it!):
// sets precision,
// then min/max value (rounded to precison and clipped to obtainable range if needed)
// then value and lineStep
KDoubleSpinBox * spin = new KDoubleSpinBox( 0, 9.999, 0.001, 4.321, 3, this );
// sets minValue to 0; maxValue to 10.00(!); value to 4.32(!) and only then
// increases the precision - too late, since e.g. value has already been rounded...
KDpubleSpinBox * spin = new KDoubleSpinBox( this );
spin->setMinValue( 0 );
spin->setMaxValue( 9.999 );
spin->setValue( 4.321 );
spin->setPrecision( 3 );
- Author:
-
Marc Mutz <mutz@kde.org>
- Version:
-
- Id:
-
knuminput.h,v 1.44 2002/09/28 15:16:22 tjansen Exp
- Since:
-
3.1
Definition at line 834 of file knuminput.h.
Constructor & Destructor Documentation
| KDoubleSpinBox::KDoubleSpinBox |
( |
QWidget * |
parent = 0, |
|
|
const char * |
name = 0 |
|
) |
|
|
|
|
Constructs a KDoubleSpinBox with parent parent and default values for range and value (whatever QRangeControl uses) and precision (2). |
| KDoubleSpinBox::KDoubleSpinBox |
( |
double |
lower, |
|
|
double |
upper, |
|
|
double |
step, |
|
|
double |
value, |
|
|
int |
precision = 2, |
|
|
QWidget * |
parent = 0, |
|
|
const char * |
name = 0 |
|
) |
|
|
|
|
Constructs a KDoubleSpinBox with parent parent, range [lower,@p upper], lineStep step, precision precision and initial value value. |
Member Function Documentation
| bool KDoubleSpinBox::acceptLocalizedNumbers |
( |
|
) |
|
|
|
|
- Returns:
-
whether the spinbox uses localized numbers
|
| double KDoubleSpinBox::lineStep |
( |
|
) |
|
|
|
|
- Returns:
-
the current step size
|
| double KDoubleSpinBox::maxValue |
( |
|
) |
|
|
|
|
- Returns:
-
the current upper bound
|
| double KDoubleSpinBox::minValue |
( |
|
) |
|
|
|
|
- Returns:
-
the current lower bound
|
| int KDoubleSpinBox::precision |
( |
|
) |
|
|
|
|
- Returns:
-
the current number of decimal points displayed.
|
| virtual void KDoubleSpinBox::setAcceptLocalizedNumbers |
( |
bool |
accept |
) |
[virtual] |
|
| void KDoubleSpinBox::setLineStep |
( |
double |
step |
) |
|
|
|
|
Sets the step size for clicking the up/down buttons to step, subject to the constraints that step is first rounded to the current precision and then clipped to the meaningful interval [1, maxValue - minValue]. |
| void KDoubleSpinBox::setMaxValue |
( |
double |
value |
) |
|
|
|
|
Sets the upper bound of the range to value, subject to the contraints that value is first rounded to the current precision and then clipped to the maximum representable interval. - See also:
-
minValue, maxValue, setMinValue, setRange
|
| void KDoubleSpinBox::setMinValue |
( |
double |
value |
) |
|
|
|
|
Sets the lower bound of the range to value, subject to the contraints that value is first rounded to the current precision and then clipped to the maximum representable interval. - See also:
-
maxValue, minValue, setMaxValue, setRange
|
| virtual void KDoubleSpinBox::setPrecision |
( |
int |
precision, |
|
|
bool |
force |
|
) |
[virtual] |
|
|
|
Sets the number of decimal points to use. Note that there is a tradeoff between the precision used and the available range of values. See the class docs for more. - Parameters:
-
| precision |
the new number of decimal points to use |
| force |
disables checking of bound violations that can arise if you increase the precision so much that the minimum and maximum values can't be represented anymore. Disabling is useful if you don't want to keep the current min and max values anyway. This is what e.g. setRange() does. |
|
| void KDoubleSpinBox::setPrecision |
( |
int |
precision |
) |
|
|
|
|
Equivalent to setPrecsion( precison, false ); Needed since Qt's moc doesn't ignore trailing parameters with default args when searching for a property setter method. |
| void KDoubleSpinBox::setRange |
( |
double |
lower, |
|
|
double |
upper, |
|
|
double |
step = 0.01, |
|
|
int |
precision = 2 |
|
) |
|
|
|
|
Sets a new range for the spin box values. Note that lower, upper and step are rounded to precision decimal points first. |
| void KDoubleSpinBox::setValidator |
( |
const QValidator * |
|
) |
|
|
| virtual void KDoubleSpinBox::setValue |
( |
double |
value |
) |
[virtual, slot] |
|
|
|
Sets the current value to value, cubject to the constraints that value is frist rounded to the current precision and then clipped to the interval [minvalue(),@p maxValue()]. |
| double KDoubleSpinBox::value |
( |
|
) |
|
|
|
|
- Returns:
-
the current value
|
| void KDoubleSpinBox::valueChanged |
( |
double |
value |
) |
[signal] |
|
|
|
Emitted whenever QSpinBox::valueChanged( int ) is emitted. |
The documentation for this class was generated from the following file:
Generated on Wed Aug 13 23:30:11 2003 for kdelibs by
1.2.18