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



    methods