# class KDoubleSpinBox

###

Table of contents
Modules
kdeui Classes
All Classes

Module | kdeui
Namespace | global
Class | KDoubleSpinBox
Inherits | QSpinBox

A spin box for fractional numbers.

This class provides a spin box for fractional numbers.

See below for code examples on how to use this class.

Parameters \n

To make successful use of KDoubleSpinBox, you need to understand the relationship between precision and available range.

- precision: The number of digits after the decimal point.
- maximum/minimum: upper and lower bounds of the valid range
- lineStep: the size of the step that is made 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 relationships hold:

    max( abs(minimum()), abs(maximum() ) <= INT_MAX/10^precision
    maxPrecision = floor( log10( INT_MAX/max(abs(minimum()),abs(maximum())) ) )

Since the value, bounds and lineStep are rounded to the current precision, you may find that the order of setting these parameters matters. As an example, the following are not equivalent (try it!):

    // sets precision,
    // then min/max value (rounded to precision and clipped to obtainable range if needed)
    // then value and lineStep
    spin = new KDoubleSpinBox( 0, 9.999, 0.001, 4.321, 3, this );

    // sets minimum to 0; maximum to 10.00(!); value to 4.32(!) and only then
    // increases the precision - too late, since e.g. value has already been rounded...
    spin = new KDoubleSpinBox( this );
    spin->setMinimum( 0 );
    spin->setMaximum( 9.999 );
    spin->setValue( 4.321 );
    spin->setPrecision( 3 );

Author Marc Mutz <mutz@kde.org>

### methods

- KDoubleSpinBox (parent)

  returns a KDoubleSpinBox object

  Argument | Type | Default
  --- | --- | ---
  parent | QWidget | None

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

- KDoubleSpinBox (lower, upper, step, value, parent, precision)

  returns a KDoubleSpinBox object

  Argument | Type | Default
  --- | --- | ---
  lower | double |
  upper | double |
  step | double |
  value | double |
  parent | QWidget |
  precision | int | 2

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

- acceptLocalizedNumbers ()

  returns (bool)

  Returns whether the spinbox uses localized numbers

- maximum ()

  returns (double)

  Returns the current upper bound

- minimum ()

  returns (double)

  Returns the current lower bound

- precision ()

  returns (int)

  Returns the current number of digits displayed to the right of the decimal point.

- setAcceptLocalizedNumbers (accept)

  returns nothing

  Argument | Type | Default
  --- | --- | ---
  accept | bool |

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

- setMaximum (value)

  returns nothing

  Argument | Type | Default
  --- | --- | ---
  value | double |

  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 range interval that can be handled at that precision.

  See also minimum, maximum, setMinimum, setRange

- setMinimum (value)

  returns nothing

  Argument | Type | Default
  --- | --- | ---
  value | double |

  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 range interval that can be handled at that precision.

  See also maximum, minimum, setMaximum, setRange

- setPrecision (precision)

  returns nothing

  Argument | Type | Default
  --- | --- | ---
  precision | int |

  Equivalent to setPrecision( precision, false ); Needed since Qt's moc doesn't ignore trailing parameters with default args when searching for a property setter method.

- setPrecision (precision, force)

  returns nothing

  Argument | Type | Default
  --- | --- | ---
  precision | int |
  force | bool |

  Sets the precision (number of digits to the right of the decimal point). Note that there is a tradeoff between the precision used and the available range of values. See the class documentation above for more information on this.

  precision - the new precision to use

  force - if true, disables checking of bounds 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 were going to disable range control in any case.

- setRange (lower, upper, step, precision)

  returns nothing

  Argument | Type | Default
  --- | --- | ---
  lower | double |
  upper | double |
  step | double | 0.01
  precision | int | 2

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

- setSingleStep (step)

  returns nothing

  Argument | Type | Default
  --- | --- | ---
  step | double |

  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, maximum() - minimum() ].

- setValidator (a0)

  returns nothing

  Argument | Type | Default
  --- | --- | ---
  a0 | QValidator |

  Overridden to ignore any setValidator() calls.

- setValue (value)

  returns nothing

  Argument | Type | Default
  --- | --- | ---
  value | double |

  Sets the current value to value, subject to the constraints that value is first rounded to the current precision and then clipped to the interval [ minimum() , maximum() ].

- singleStep ()

  returns (double)

  Returns the current step size

- slotValueChanged (value)

  returns nothing

  Argument | Type | Default
  --- | --- | ---
  value | int |

- textFromValue (a0)

  returns (QString)

  Argument | Type | Default
  --- | --- | ---
  a0 | int |

- value ()

  returns (double)

  Returns the current value

- valueChanged (value) signal

  returns nothing
  SIGNAL ("valueChanged (double)")

  Argument | Type | Default
  --- | --- | ---
  value | double |

  Emitted whenever QSpinBox.valueChanged( int ) is emitted.

- valueFromText (text)

  returns (int)

  Argument | Type | Default
  --- | --- | ---
  text | QString |