class KDoubleSpinBox

A spin box for fractional numbers. More...

Definition#include <knuminput.h>
InheritsQSpinBox (qt) [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods

Public Slots

Signals

Protected Methods

Protected Slots


Detailed Description

This class provides a spin box for fractional numbers.

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.

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 );

 KDoubleSpinBox ( QWidget * parent=0, const char * name=0 )

KDoubleSpinBox

Constructs a KDoubleSpinBox with parent parent and default values for range and value (whatever QRangeControl uses) and precision (2).

 KDoubleSpinBox ( double lower, double upper, double step, double value, int precision=2, QWidget * parent=0, const char * name=0 )

KDoubleSpinBox

Constructs a KDoubleSpinBox with parent parent, range [lower,upper], lineStep step, precision precision and initial value value.

 ~KDoubleSpinBox ()

~KDoubleSpinBox

[virtual]

bool  acceptLocalizedNumbers ()

acceptLocalizedNumbers

[const]

void  setAcceptLocalizedNumbers ( bool accept )

setAcceptLocalizedNumbers

[virtual]

Sets whether to use and accept localized numbers as returned by KLocale::formatNumber()

void  setRange ( double lower, double upper, double step=0.01, int precision=2 )

setRange

Sets a new range for the spin box values. Note that lower, upper and step are rounded to precision decimal points first.

int  precision ()

precision

[const]

void  setPrecision ( int precision )

setPrecision

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  setPrecision ( int precision, bool force )

setPrecision

[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:
precisionthe new number of decimal points to use
forcedisables 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.

double  value ()

value

[const]

double  minValue ()

minValue

[const]

void  setMinValue ( double value )

setMinValue

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

double  maxValue ()

maxValue

[const]

void  setMaxValue ( double value )

setMaxValue

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

double  lineStep ()

lineStep

[const]

void  setLineStep ( double step )

setLineStep

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  setValidator ( const QValidator * )

setValidator

void  valueChanged ( double value )

valueChanged

[signal]

void  setValue ( double value )

setValue

[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(),maxValue()].

QString  mapValueToText (int)

mapValueToText

[protected virtual]

Reimplemented from QSpinBox.

int  mapTextToValue (bool*)

mapTextToValue

[protected virtual]

Reimplemented from QSpinBox.

void  slotValueChanged ( int value )

slotValueChanged

[protected slots slot]

void  virtual_hook ( int id, void* data )

virtual_hook

[protected virtual]