kdeui Library API Documentation

KIntNumInput Class Reference

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

#include <knuminput.h>

Inheritance diagram for KIntNumInput:

KNumInput QWidget List of all members.

Public Slots

void setValue (int)
 Sets the value of the control.

void setRelativeValue (double)
 Sets the value in units of the referencePoint
Since:
3.1.


void setReferencePoint (int)
 Sets the reference point for relativeValue.

void setSuffix (const QString &suffix)
 Sets the suffix to suffix.

void setPrefix (const QString &prefix)
 Sets the prefix to prefix.

void setEditFocus (bool mark=true)
 sets focus to the edit widget and marks all text in if mark == true


Signals

void valueChanged (int)
 Emitted every time the value changes (by calling setValue() or by user interaction).

void relativeValueChanged (double)
 Emitted whenever valueChanged is.


Public Member Functions

 KIntNumInput (QWidget *parent=0, const char *name=0)
 Constructs an input control for integer values with base 10 and initial value 0.

 KIntNumInput (int value, QWidget *parent=0, int base=10, const char *name=0)
 Constructor It constructs a QSpinBox that allows the input of integer numbers in the range of -INT_MAX to +INT_MAX.

 KIntNumInput (KNumInput *below, int value, QWidget *parent=0, int base=10, const char *name=0)
 Constructor.

virtual ~KIntNumInput ()
 Destructor.

int value () const
double relativeValue () const
int referencePoint () const
QString suffix () const
QString prefix () const
QString specialValueText () const
void setRange (int min, int max, int step=1, bool slider=true)
void setMinValue (int min)
 Sets the minimum value.

int minValue () const
void setMaxValue (int max)
 Sets the maximum value.

int maxValue () 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
 This method returns the minimum size necessary to display the control.


Protected Member Functions

virtual void doLayout ()
 You need to overwrite this method and implement your layout calculations there.

void resizeEvent (QResizeEvent *)
virtual void virtual_hook (int id, void *data)

Protected Attributes

KIntSpinBoxm_spin
QSize m_sizeSpin

Detailed Description

KIntNumInput combines a QSpinBox and optionally a QSlider with a label to make an easy to use control for setting some integer parameter. An input widget for integer 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 KIntNumInput, designed specifically for the situation when there are several KIntNumInputs 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 KIntValidator validator class. KIntNumInput enforces the value to be in the given range, and can display it in any base between 2 and 36.

Version:
Id
knuminput.h,v 1.44 2002/09/28 15:16:22 tjansen Exp

Definition at line 181 of file knuminput.h.


Constructor & Destructor Documentation

KIntNumInput::KIntNumInput QWidget parent = 0,
const char *  name = 0
 

Constructs an input control for integer values with base 10 and initial value 0.

Definition at line 271 of file knuminput.cpp.

References KStdAccel::name().

KIntNumInput::KIntNumInput int  value,
QWidget parent = 0,
int  base = 10,
const char *  name = 0
 

Constructor It constructs a QSpinBox that allows the input of integer numbers in the range of -INT_MAX to +INT_MAX.

To set a descriptive label, use setLabel(). To enforce the value being in a range and optionally to attach a slider to it, use setRange().

Parameters:
value initial value for the control
base numeric base used for display
parent parent QWidget
name internal name for this widget

Definition at line 277 of file knuminput.cpp.

References KStdAccel::name().

KIntNumInput::KIntNumInput KNumInput below,
int  value,
QWidget parent = 0,
int  base = 10,
const char *  name = 0
 

Constructor.

the difference to the one above is the "below" parameter. It tells this instance that it is visually put below some other KNumInput widget. Note that these two KNumInput's need not to have the same parent widget or be in the same layout group. The effect is that it'll adjust it's layout in correspondence with the layout of the other KNumInput's (you can build an arbitary long chain).

Parameters:
below append KIntNumInput to the KNumInput chain
value initial value for the control
base numeric base used for display
parent parent QWidget
name internal name for this widget

Definition at line 264 of file knuminput.cpp.

References KStdAccel::name().

KIntNumInput::~KIntNumInput  )  [virtual]
 

Destructor.

Definition at line 467 of file knuminput.cpp.


Member Function Documentation

int KIntNumInput::value  )  const
 

Returns:
the current value.

Definition at line 490 of file knuminput.cpp.

References QSpinBox::value().

Referenced by relativeValue().

double KIntNumInput::relativeValue  )  const
 

Returns:
the curent value in units of the referencePoint.
Since:
3.1

Definition at line 485 of file knuminput.cpp.

References value().

int KIntNumInput::referencePoint  )  const
 

Returns:
the current reference point
Since:
3.1

Definition at line 303 of file knuminput.cpp.

Referenced by setRange().

QString KIntNumInput::suffix  )  const
 

Returns:
the suffix displayed behind the value.
See also:
setSuffix()

Definition at line 386 of file knuminput.cpp.

References QSpinBox::suffix().

QString KIntNumInput::prefix  )  const
 

Returns:
the prefix displayed in front of the value.
See also:
setPrefix()

Definition at line 398 of file knuminput.cpp.

References QSpinBox::prefix().

QString KIntNumInput::specialValueText  )  const
 

Returns:
the string displayed for a special value.
See also:
setSpecialValueText()

Definition at line 501 of file knuminput.cpp.

References QSpinBox::specialValueText().

void KIntNumInput::setRange int  min,
int  max,
int  step = 1,
bool  slider = true
 

Parameters:
min minimum value
max maximum value
step step size for the QSlider

Definition at line 320 of file knuminput.cpp.

References QWidget::layout(), QSpinBox::lineStep(), referencePoint(), QSpinBox::setLineStep(), QSpinBox::setMaxValue(), QSpinBox::setMinValue(), QSlider::setRange(), setReferencePoint(), QSlider::setTickInterval(), QSlider::setTickmarks(), setValue(), QSpinBox::value(), and valueChanged().

Referenced by setMaxValue(), and setMinValue().

void KIntNumInput::setMinValue int  min  ) 
 

Sets the minimum value.

Definition at line 359 of file knuminput.cpp.

References QSpinBox::lineStep(), QSpinBox::maxValue(), and setRange().

Referenced by KFontChooser::KFontChooser().

int KIntNumInput::minValue  )  const
 

Returns:
the minimum value.

Definition at line 364 of file knuminput.cpp.

References QSpinBox::minValue().

Referenced by setReferencePoint().

void KIntNumInput::setMaxValue int  max  ) 
 

Sets the maximum value.

Definition at line 369 of file knuminput.cpp.

References QSpinBox::lineStep(), QSpinBox::minValue(), and setRange().

int KIntNumInput::maxValue  )  const
 

Returns:
the maximum value.

Definition at line 374 of file knuminput.cpp.

References QSpinBox::maxValue().

Referenced by setReferencePoint().

void KIntNumInput::setSpecialValueText const QString text  ) 
 

Sets the special value text.

If set, the SpinBox 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 495 of file knuminput.cpp.

References QWidget::layout(), and QSpinBox::setSpecialValueText().

void KIntNumInput::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 506 of file knuminput.cpp.

References KStdAccel::label(), QLabel::setBuddy(), and KNumInput::setLabel().

QSize KIntNumInput::minimumSizeHint  )  const [virtual]
 

This method returns the minimum size necessary to display the control.

The minimum size is enough to show all the labels in the current font (font change may invalidate the return value).

Returns:
the minimum size necessary to show the control

Reimplemented from QWidget.

Definition at line 408 of file knuminput.cpp.

References QWidget::constPolish(), QSize::height(), and QSize::width().

void KIntNumInput::setValue int   )  [slot]
 

Sets the value of the control.

Definition at line 472 of file knuminput.cpp.

References QSpinBox::setValue().

Referenced by setRange(), and setRelativeValue().

void KIntNumInput::setRelativeValue double   )  [slot]
 

Sets the value in units of the referencePoint

Since:
3.1.

Definition at line 478 of file knuminput.cpp.

References setValue().

void KIntNumInput::setReferencePoint int   )  [slot]
 

Sets the reference point for relativeValue.

Since:
3.1

Definition at line 297 of file knuminput.cpp.

References maxValue(), and minValue().

Referenced by setRange().

void KIntNumInput::setSuffix const QString suffix  )  [slot]
 

Sets the suffix to suffix.

Use QString::null to disable this feature. Formatting has to be provided (e.g. a space separator between the prepended value and the suffix's text has to be provided as the first character in the suffix).

See also:
QSpinBox::setSuffix(), setPrefix()

Definition at line 379 of file knuminput.cpp.

References QWidget::layout(), and QSpinBox::setSuffix().

void KIntNumInput::setPrefix const QString prefix  )  [slot]
 

Sets the prefix to prefix.

Use QString::null to disable this feature. Formatting has to be provided (see above).

See also:
QSpinBox::setPrefix(), setSuffix()

Definition at line 391 of file knuminput.cpp.

References QWidget::layout(), and QSpinBox::setPrefix().

void KIntNumInput::setEditFocus bool  mark = true  )  [slot]
 

sets focus to the edit widget and marks all text in if mark == true

Definition at line 403 of file knuminput.cpp.

References KIntSpinBox::setEditFocus().

void KIntNumInput::valueChanged int   )  [signal]
 

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

Referenced by setRange().

void KIntNumInput::relativeValueChanged double   )  [signal]
 

Emitted whenever valueChanged is.

Contains the change relative to the referencePoint.

Since:
3.1

void KIntNumInput::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 433 of file knuminput.cpp.

References QLabel::setBuddy(), and QSize::width().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sun Feb 27 22:15:08 2005 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001