KDoubleSpinBox Class Reference
A spin box for fractional numbers. More...
#include <knuminput.h>
Inheritance diagram for KDoubleSpinBox:


Public Slots | |
virtual void | setValue (double value) |
Signals | |
void | valueChanged (double value) |
Public Member Functions | |
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) | |
virtual | ~KDoubleSpinBox () |
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 *) |
Protected Slots | |
void | slotValueChanged (int value) |
Protected Member Functions | |
virtual QString | mapValueToText (int) |
virtual int | mapTextToValue (bool *) |
virtual void | virtual_hook (int id, void *data) |
Properties | |
bool | acceptLocalizedNumbers |
int | precision |
Detailed Description
A spin box for fractional numbers.This class provides a spin box for fractional numbers.

KDE Fractional Number Spinbox
Parameters
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.
- maxValue/minValue: 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
max( abs(minValue()), abs(maxValue() ) <= INT_MAX/10^precision maxPrecision = floor( log10( INT_MAX/max(abs(minValue()),abs(maxValue())) ) )
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 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... KDoubleSpinBox * 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$
- Since:
- 3.1
Definition at line 834 of file knuminput.h.
Constructor & Destructor Documentation
|
Constructs a KDoubleSpinBox with parent
Definition at line 996 of file knuminput.cpp. References QSpinBox::editor(), slotValueChanged(), and valueChanged(). |
|
Constructs a KDoubleSpinBox with parent
Definition at line 1005 of file knuminput.cpp. References QSpinBox::editor(), setRange(), setValue(), slotValueChanged(), and valueChanged(). |
Member Function Documentation
|
Referenced by mapTextToValue(), and mapValueToText(). |
|
Sets whether to use and accept localized numbers as returned by KLocale::formatNumber().
Definition at line 1027 of file knuminput.cpp. |
|
Sets a new range for the spin box values.
Note that Definition at line 1032 of file knuminput.cpp. References setLineStep(), setMaxValue(), setMinValue(), and setPrecision(). Referenced by KDoubleSpinBox(). |
|
|
|
Equivalent to setPrecision(
Definition at line 1046 of file knuminput.cpp. Referenced by setRange(). |
|
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.
Definition at line 1050 of file knuminput.cpp. |
|
Definition at line 1072 of file knuminput.cpp. References QSpinBox::value(). Referenced by KInputDialog::getDouble(). |
|
Definition at line 1089 of file knuminput.cpp. References QSpinBox::minValue(). Referenced by mapTextToValue(), setLineStep(), and setValue(). |
|
Sets the lower bound of the range to
Definition at line 1093 of file knuminput.cpp. References QSpinBox::setMinValue(). Referenced by setRange(). |
|
Definition at line 1102 of file knuminput.cpp. References QSpinBox::maxValue(). Referenced by mapTextToValue(), setLineStep(), and setValue(). |
|
Sets the upper bound of the range to
Definition at line 1106 of file knuminput.cpp. References QSpinBox::setMaxValue(). Referenced by setRange(). |
|
Definition at line 1114 of file knuminput.cpp. References QSpinBox::lineStep(). |
|
Sets the step size for clicking the up/down buttons to
Definition at line 1118 of file knuminput.cpp. References maxValue(), minValue(), and QSpinBox::setLineStep(). Referenced by setRange(). |
|
Overridden to ignore any setValidator() calls.
Reimplemented from QSpinBox. Definition at line 1148 of file knuminput.cpp. |
|
Emitted whenever QSpinBox::valueChanged( int ) is emitted.
Referenced by KDoubleSpinBox(), and slotValueChanged(). |
|
Sets the current value to
Definition at line 1076 of file knuminput.cpp. References QSpinBox::maxValue(), maxValue(), QSpinBox::minValue(), minValue(), and QSpinBox::setValue(). Referenced by KDoubleSpinBox(). |
The documentation for this class was generated from the following files: