| # kdeui Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# KDoubleNumInput Class Reference

KDoubleNumInput combines a QSpinBox and optionally a QSlider with a label to make an easy to use control for setting some float parameter. An input control for real numbers, consisting of a spinbox and a slider. More...

`#include <knuminput.h>`

Inheritance diagram for KDoubleNumInput:

[legend]
Collaboration diagram for KDoubleNumInput:

[legend]
List of all members.

## Public Slots
void | setValue (double)
| Sets the value of the control.
void | setRelativeValue (double)
| Sets the value in units of referencePoint.
void | setReferencePoint (double ref)
| Sets the reference Point to `ref`.
void | setSuffix (const QString &suffix)
| Sets the suffix to be displayed to `suffix`.
void | setPrefix (const QString &prefix)
| Sets the prefix to be displayed to `prefix`.
## Signals
void | valueChanged (double)
| Emitted every time the value changes (by calling setValue() or by user interaction).
void | relativeValueChanged (double)
| This is an overloaded member function, provided for convenience.
## Public Member Functions
| KDoubleNumInput (QWidget *parent=0, const char *name=0)
| Constructs an input control for double values with initial value 0.00.
| KDoubleNumInput (double value, QWidget *parent=0, const char *name=0)
| This class or method is obsolete, it is provided for compatibility only. (value is rounded to a multiple of 1/100) Constructor
| KDoubleNumInput (double lower, double upper, double value, double step=0.01, int precision=2, QWidget *parent=0, const char *name=0)
| Constructor.
virtual | ~KDoubleNumInput ()
| destructor
| KDoubleNumInput (KNumInput *below, double value, QWidget *parent=0, const char *name=0)
| This class or method is obsolete, it is provided for compatibility only. (rounds `value` to a mulitple of 1/100) Constructor
| KDoubleNumInput (KNumInput *below, double lower, double upper, double value, double step=0.02, int precision=2, QWidget *parent=0, const char *name=0)
| Constructor.
double | value () const
QString | suffix () const
QString | prefix () const
int | precision () const
QString | specialValueText () const
void | setRange (double min, double max, double step=1, bool slider=true)
void | setMinValue (double min)
| Sets the minimum value.
double | minValue () const
void | setMaxValue (double max)
| Sets the maximum value.
double | maxValue () const
void | setPrecision (int precision)
| Specifies the number of digits to use.
double | referencePoint () const
double | relativeValue () const
void | setSpecialValueText (const QString &text)
| Sets the special value text.
virtual void | setLabel (const QString &label, int a=AlignLeft|AlignTop)
| Sets the text and alignment of the main description label.
virtual QSize | minimumSizeHint () const
virtual bool | eventFilter (QObject *, QEvent *)
## Protected Member Functions
virtual void | doLayout ()
| You need to overwrite this method and implement your layout calculations there.
void | resizeEvent (QResizeEvent *)
virtual void | resetEditBox ()
virtual void | virtual_hook (int id, void *data)
## Protected Attributes
KDoubleLine * | edit
bool | m_range
double | m_lower
double | m_upper
double | m_step
QSize | m_sizeEdit
## Friends
class | KDoubleLine

## Detailed Description

KDoubleNumInput combines a QSpinBox and optionally a QSlider with a label to make an easy to use control for setting some float parameter. An input control for real numbers, consisting of a spinbox and a slider.

This is especially nice for configuration dialogs, which can have many such combinated controls.

The slider is created only when the user specifies a range for the control using the setRange function with the slider parameter set to "true".

A special feature of KDoubleNumInput, designed specifically for the situation when there are several instances in a column, is that you can specify what portion of the control is taken by the QSpinBox (the remaining portion is used by the slider). This makes it very simple to have all the sliders in a column be the same size.

It uses the KDoubleValidator validator class. KDoubleNumInput enforces the value to be in the given range, but see the class documentation of KDoubleSpinBox for the tricky interrelationship of precision and values. All of what is said there applies here, too.

See also:
  KIntNumInput, KDoubleSpinBox

Definition at line 432 of file knuminput.h.

## Constructor & Destructor Documentation

KDoubleNumInput::KDoubleNumInput | ( | QWidget * | parent = 0,
|  | const char * | name = 0
| ) |

| Constructs an input control for double values with initial value 0.00. Definition at line 527 of file knuminput.cpp. References KStdAccel::name().

KDoubleNumInput::KDoubleNumInput | ( | double | value,
|  | QWidget * | parent = 0,
|  | const char * | name = 0
| ) |

  | This class or method is obsolete, it is provided for compatibility only. (value is rounded to a multiple of 1/100) Constructor Parameters:
  value | initial value for the control
  parent | parent QWidget
  name | internal name for this widget
Definition at line 550 of file knuminput.cpp. References KStdAccel::name().

KDoubleNumInput::KDoubleNumInput | ( | double | lower,
|  | double | upper,
|  | double | value,
|  | double | step = 0.01,
|  | int | precision = 2,
|  | QWidget * | parent = 0,
|  | const char * | name = 0
| ) |

  | Constructor. Parameters:
  lower | lower boundary value
  upper | upper boundary value
  value | initial value for the control
  step | step size to use for up/down arrow clicks
  precision | number of digits after the decimal point
  parent | parent QWidget
  name | internal name for this widget
Since: 3.1 Definition at line 533 of file knuminput.cpp. References KStdAccel::name().

KDoubleNumInput::~KDoubleNumInput | ( |  | ) | `[virtual]`

| destructor Definition at line 563 of file knuminput.cpp.

KDoubleNumInput::KDoubleNumInput | ( | KNumInput * | below,
|  | double | value,
|  | QWidget * | parent = 0,
|  | const char * | name = 0
| ) |

  | This class or method is obsolete, it is provided for compatibility only. (rounds `value` to a mulitple of 1/100) Constructor puts it below other KNumInput Parameters:
  below |
  value | initial value for the control
  parent | parent QWidget
  name | internal name for this widget
Definition at line 556 of file knuminput.cpp. References KStdAccel::name().

KDoubleNumInput::KDoubleNumInput | ( | KNumInput * | below,
|  | double | lower,
|  | double | upper,
|  | double | value,
|  | double | step = 0.02,
|  | int | precision = 2,
|  | QWidget * | parent = 0,
|  | const char * | name = 0
| ) |

  | Constructor. puts it below other KNumInput Parameters:
  lower | lower boundary value
  upper | upper boundary value
  value | initial value for the control
  step | step size to use for up/down arrow clicks
  precision | number of digits after the decimal point
  parent | parent QWidget
  name | internal name for this widget
Since: 3.1 Definition at line 541 of file knuminput.cpp. References KStdAccel::name().

## Member Function Documentation

double KDoubleNumInput::value | ( |  | ) | const

| Returns: the current value. Definition at line 783 of file knuminput.cpp. Referenced by relativeValue().

QString KDoubleNumInput::suffix | ( |  | ) | const

| Returns: the suffix. See also: setSuffix() Definition at line 799 of file knuminput.cpp.

QString KDoubleNumInput::prefix | ( |  | ) | const

| Returns: the prefix. See also: setPrefix() Definition at line 804 of file knuminput.cpp.

int KDoubleNumInput::precision | ( |  | ) | const

| Returns: the precision. See also: setPrecision() Definition at line 830 of file knuminput.cpp.

QString KDoubleNumInput::specialValueText | ( |  | ) | const`[inline]`

| Returns: the string displayed for a special value. See also: setSpecialValueText() Definition at line 537 of file knuminput.h.

void KDoubleNumInput::setRange | ( | double | min,
|  | double | max,
|  | double | step = 1,
|  | bool | slider = true
| ) |

  | Parameters:
  min | minimum value
  max | maximum value
  step | step size for the QSlider
Definition at line 716 of file knuminput.cpp. References QWidget::layout(), QSpinBox::lineStep(), QSpinBox::maxValue(), QSpinBox::minValue(), referencePoint(), QSlider::setLineStep(), QSlider::setRange(), setReferencePoint(), QSlider::setTickInterval(), QSlider::setTickmarks(), QSlider::setValue(), setValue(), QSpinBox::value(), and valueChanged(). Referenced by setMaxValue(), and setMinValue().

void KDoubleNumInput::setMinValue | ( | double | min | ) |

| Sets the minimum value. Definition at line 763 of file knuminput.cpp. References maxValue(), and setRange().

double KDoubleNumInput::minValue | ( |  | ) | const

| Returns: the minimum value. Definition at line 768 of file knuminput.cpp. Referenced by setMaxValue(), and setReferencePoint().

void KDoubleNumInput::setMaxValue | ( | double | max | ) |

| Sets the maximum value. Definition at line 773 of file knuminput.cpp. References minValue(), and setRange().

double KDoubleNumInput::maxValue | ( |  | ) | const

| Returns: the maximum value. Definition at line 778 of file knuminput.cpp. Referenced by setMinValue(), and setReferencePoint().

void KDoubleNumInput::setPrecision | ( | int | precision | ) |

| Specifies the number of digits to use. Definition at line 823 of file knuminput.cpp. References QWidget::layout().

double KDoubleNumInput::referencePoint | ( |  | ) | const

| Returns: the reference point for relativeValue calculation Since: 3.1 Definition at line 794 of file knuminput.cpp. Referenced by setRange().

double KDoubleNumInput::relativeValue | ( |  | ) | const

| Returns: the current value in units of referencePoint. Since: 3.1 Definition at line 788 of file knuminput.cpp. References value().

void KDoubleNumInput::setSpecialValueText | ( | const QString & | text | ) |

| Sets the special value text. If set, the spin box will display this text instead of the numeric value whenever the current value is equal to minVal(). Typically this is used for indicating that the choice has a special (default) meaning. Definition at line 835 of file knuminput.cpp. References QWidget::layout().

void KDoubleNumInput::setLabel | ( | const QString & | label,
|  | int | a = AlignLeft|AlignTop
| ) | `[virtual]`

  | Sets the text and alignment of the main description label. Parameters:
  label | The text of the label. Use QString::null to remove an existing one.
  a | one of `AlignLeft`, `AlignHCenter`, YAlignRight and `AlignTop`, `AlignVCenter`, `AlignBottom`. default is `AlignLeft` | `AlignTop`.
The vertical alignment flags have special meaning with this widget: `AlignTop` The label is placed above the edit/slider `AlignVCenter` The label is placed left beside the edit `AlignBottom` The label is placed below the edit/slider Reimplemented from KNumInput. Definition at line 843 of file knuminput.cpp. References KStdAccel::label(), QLabel::setBuddy(), and KNumInput::setLabel().

void KDoubleNumInput::setValue | ( | double |  | ) | `[slot]`

| Sets the value of the control. Definition at line 696 of file knuminput.cpp. Referenced by setRange(), and setRelativeValue().

void KDoubleNumInput::setRelativeValue | ( | double |  | ) | `[slot]`

| Sets the value in units of referencePoint. Since: 3.1 Definition at line 701 of file knuminput.cpp. References setValue().

void KDoubleNumInput::setReferencePoint | ( | double | ref | ) | `[slot]`

| Sets the reference Point to `ref`. It `ref` == 0, emitting of relativeValueChanged is blocked and relativeValue just returns 0. Since: 3.1 Definition at line 709 of file knuminput.cpp. References maxValue(), and minValue(). Referenced by setRange().

void KDoubleNumInput::setSuffix | ( | const QString & | suffix | ) | `[slot]`

| Sets the suffix to be displayed to `suffix`. Use QString::null to disable this feature. Note that the suffix is attached to the value without any spacing. So if you prefer to display a space separator, set suffix to something like " cm". See also: setSuffix() Definition at line 809 of file knuminput.cpp. References QWidget::layout().

void KDoubleNumInput::setPrefix | ( | const QString & | prefix | ) | `[slot]`

| Sets the prefix to be displayed to `prefix`. Use QString::null to disable this feature. Note that the prefix is attached to the value without any spacing. See also: setPrefix() Definition at line 816 of file knuminput.cpp. References QWidget::layout().

void KDoubleNumInput::valueChanged | ( | double |  | ) | `[signal]`

| Emitted every time the value changes (by calling setValue() or by user interaction). Referenced by setRange().

void KDoubleNumInput::relativeValueChanged | ( | double |  | ) | `[signal]`

| This is an overloaded member function, provided for convenience. It essentially behaves like the above function. Contains the value in units of referencePoint. Since: 3.1

void KDoubleNumInput::doLayout | ( |  | ) | `[protected, virtual]`

| You need to overwrite this method and implement your layout calculations there. See KIntNumInput::doLayout and KDoubleNumInput::doLayout implementation for details. Implements KNumInput. Definition at line 690 of file knuminput.cpp. References QSize::width().

The documentation for this class was generated from the following files:

- knuminput.h
- knuminput.cpp

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:00:45 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001