Main Page | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members | Related Pages

QwtCounter Class Reference

The Counter Widget. More...

#include <qwt_counter.h>

Inheritance diagram for QwtCounter:

QwtDblRange List of all members.

Public Types

enum  Button { Button1, Button2, Button3, ButtonCnt }

Signals

void buttonReleased (double value)
void valueChanged (double value)

Public Member Functions

 QwtCounter (QWidget *parent=0, const char *name=0)
double step () const
void setStep (double s)
double minVal () const
void setMinValue (double m)
double maxVal () const
void setMaxValue (double m)
void setStepButton1 (int nSteps)
int stepButton1 () const
void setStepButton2 (int nSteps)
int stepButton2 () const
void setStepButton3 (int nSteps)
int stepButton3 () const
virtual double value () const
void setNumButtons (int n)
int numButtons () const
void setIncSteps (QwtCounter::Button btn, int nSteps)
int incSteps (QwtCounter::Button btn) const
virtual void setValue (double)
virtual QSizePolicy sizePolicy () const
virtual QSize sizeHint () const

Protected Member Functions

virtual void fontChange (const QFont &f)

Private Slots

void btnReleased ()
void btnClicked ()

Private Member Functions

void updateButtons ()
void showNum (double)
virtual void valueChange ()

Private Attributes

QwtArrowButtond_buttonDown [ButtonCnt]
QwtArrowButtond_buttonUp [ButtonCnt]
QLineEdit * d_valueEdit
int d_increment [ButtonCnt]
int d_nButtons

Detailed Description

The Counter Widget.

A Counter consists of a label displaying a number and one ore more (up to three) push buttons on each side of the label which can be used to increment or decrement the counter's value.

A Counter has a range from a minimum value to a maximum value and a step size. The range can be specified using QwtDblRange::setRange(). The counter's value is an integer multiple of the step size. The number of steps by which a button increments or decrements the value can be specified using QwtCounter::setIncSteps(). The number of buttons can be changed with QwtCounter::setNumButtons().

Example:

#include "../include/qwt_counter.h>

QwtCounter *cnt;

cnt = new QwtCounter(parent, name);

cnt->setRange(0.0, 100.0, 1.0);             // From 0.0 to 100, step 1.0
cnt->setNumButtons(2);                      // Two buttons each side
cnt->setIncSteps(QwtCounter::Button1, 1);   // Button 1 increments 1 step
cnt->setIncSteps(QwtCounter::Button2, 20);  // Button 2 increments 20 steps

connect(cnt, SIGNAL(valueChanged(double)), my_class, SLOT(newValue(double)));

Definition at line 54 of file qwt_counter.h.


Member Enumeration Documentation

enum QwtCounter::Button
 

Button index

Enumeration values:
Button1 
Button2 
Button3 
ButtonCnt 

Definition at line 72 of file qwt_counter.h.


Constructor & Destructor Documentation

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

The default number of buttons is set to 2. The default increments are:

  • Button 1: 1 step
  • Button 2: 10 steps
  • Button 3: 100 steps
Parameters:
parent 
name Forwarded to QWidget's ctor.

Definition at line 24 of file qwt_counter.cpp.

References btnClicked(), btnReleased(), Button1, Button2, Button3, ButtonCnt, d_buttonDown, d_buttonUp, d_increment, d_valueEdit, setNumButtons(), QwtDblRange::setRange(), and setValue().


Member Function Documentation

void QwtCounter::btnClicked  )  [private, slot]
 

Button clicked.

Definition at line 182 of file qwt_counter.cpp.

References ButtonCnt, d_buttonDown, d_buttonUp, d_increment, and QwtDblRange::incValue().

Referenced by QwtCounter().

void QwtCounter::btnReleased  )  [private, slot]
 

Button released.

Definition at line 195 of file qwt_counter.cpp.

References buttonReleased(), and value().

Referenced by QwtCounter().

void QwtCounter::buttonReleased double  value  )  [signal]
 

This signal is emitted when a button has been released

Parameters:
value The new value

Referenced by btnReleased().

void QwtCounter::fontChange const QFont &  f  )  [protected, virtual]
 

Notify change of font.

This function updates the fonts of all widgets contained in QwtCounter.

Parameters:
f new font

Definition at line 207 of file qwt_counter.cpp.

References d_valueEdit.

int QwtCounter::incSteps QwtCounter::Button  btn  )  const
 

Returns:
the number of steps by which a specified button increments the value or 0 if the button is invalid.
Parameters:
btn One of QwtCounter::Button1, QwtCounter::Button2, QwtCounter::Button3

Definition at line 91 of file qwt_counter.cpp.

References ButtonCnt, and d_increment.

double QwtCounter::maxVal  )  const [inline]
 

Definition at line 80 of file qwt_counter.h.

References QwtDblRange::maxValue().

double QwtCounter::minVal  )  const [inline]
 

Definition at line 78 of file qwt_counter.h.

References QwtDblRange::minValue().

int QwtCounter::numButtons  )  const
 

Returns:
The number of buttons on each side of the widget.

Definition at line 166 of file qwt_counter.cpp.

References d_nButtons.

void QwtCounter::setIncSteps QwtCounter::Button  btn,
int  nSteps
 

Specify the number of steps by which the value is incremented or decremented when a specified button is pushed.

Parameters:
btn One of QwtCounter::Button1, QwtCounter::Button2, QwtCounter::Button3
nSteps Number of steps

Definition at line 79 of file qwt_counter.cpp.

References ButtonCnt, and d_increment.

void QwtCounter::setMaxValue double  m  )  [inline]
 

Definition at line 81 of file qwt_counter.h.

References QwtDblRange::minValue(), QwtDblRange::setRange(), and QwtDblRange::step().

void QwtCounter::setMinValue double  m  )  [inline]
 

Definition at line 79 of file qwt_counter.h.

References QwtDblRange::maxValue(), QwtDblRange::setRange(), and QwtDblRange::step().

void QwtCounter::setNumButtons int  n  ) 
 

Specify the number of buttons on each side of the label.

Parameters:
n Number of buttons

Definition at line 141 of file qwt_counter.cpp.

References ButtonCnt, d_buttonDown, d_buttonUp, and d_nButtons.

Referenced by QwtCounter().

void QwtCounter::setStep double  s  )  [inline]
 

Change the step raster.

Parameters:
vstep new step width
Warning:
The value will not be adjusted to the new step raster.

Reimplemented from QwtDblRange.

Definition at line 77 of file qwt_counter.h.

References QwtDblRange::setStep().

void QwtCounter::setStepButton1 int  nSteps  )  [inline]
 

Definition at line 82 of file qwt_counter.h.

void QwtCounter::setStepButton2 int  nSteps  )  [inline]
 

Definition at line 84 of file qwt_counter.h.

void QwtCounter::setStepButton3 int  nSteps  )  [inline]
 

Definition at line 86 of file qwt_counter.h.

void QwtCounter::setValue double  v  )  [virtual]
 

Set a new value.

Parameters:
v new value Calls QwtDblRange::setValue and does all visual updates.
See also:
QwtDblRange::setValue

Reimplemented from QwtDblRange.

Definition at line 106 of file qwt_counter.cpp.

References QwtDblRange::setValue(), showNum(), updateButtons(), and value().

Referenced by QwtCounter().

void QwtCounter::showNum double   )  [private]
 

Display number string.

Definition at line 172 of file qwt_counter.cpp.

References d_valueEdit.

Referenced by setValue(), and valueChange().

QSize QwtCounter::sizeHint  )  const [virtual]
 

A size hint.

Definition at line 214 of file qwt_counter.cpp.

References d_valueEdit, QwtDblRange::maxValue(), QwtDblRange::minValue(), and step().

QSizePolicy QwtCounter::sizePolicy  )  const [virtual]
 

Returns:
Preferred/Fixed

Definition at line 244 of file qwt_counter.cpp.

double QwtCounter::step  )  const [inline]
 

Returns:
the step size
See also:
QwtDblRange::setStep, QwtDblRange::setRange

Reimplemented from QwtDblRange.

Definition at line 76 of file qwt_counter.h.

References QwtDblRange::step().

Referenced by sizeHint().

int QwtCounter::stepButton1  )  const [inline]
 

Definition at line 83 of file qwt_counter.h.

int QwtCounter::stepButton2  )  const [inline]
 

Definition at line 85 of file qwt_counter.h.

int QwtCounter::stepButton3  )  const [inline]
 

Definition at line 87 of file qwt_counter.h.

void QwtCounter::updateButtons  )  [private]
 

Update buttons according to the current value.

Definition at line 128 of file qwt_counter.cpp.

References ButtonCnt, d_buttonDown, d_buttonUp, QwtDblRange::maxValue(), QwtDblRange::minValue(), and value().

Referenced by setValue(), and valueChange().

virtual double QwtCounter::value  )  const [inline, virtual]
 

Returns the current value.

Reimplemented from QwtDblRange.

Definition at line 88 of file qwt_counter.h.

References QwtDblRange::value().

Referenced by btnReleased(), setValue(), updateButtons(), and valueChange().

void QwtCounter::valueChange  )  [private, virtual]
 

Notify a change of value.

Reimplemented from QwtDblRange.

Definition at line 117 of file qwt_counter.cpp.

References showNum(), updateButtons(), value(), and valueChanged().

void QwtCounter::valueChanged double  value  )  [signal]
 

This signal is emitted when the counter's value has changed

Parameters:
value The new value

Referenced by valueChange().


Member Data Documentation

QwtArrowButton* QwtCounter::d_buttonDown[ButtonCnt] [private]
 

Definition at line 125 of file qwt_counter.h.

Referenced by btnClicked(), QwtCounter(), setNumButtons(), and updateButtons().

QwtArrowButton* QwtCounter::d_buttonUp[ButtonCnt] [private]
 

Definition at line 126 of file qwt_counter.h.

Referenced by btnClicked(), QwtCounter(), setNumButtons(), and updateButtons().

int QwtCounter::d_increment[ButtonCnt] [private]
 

Definition at line 129 of file qwt_counter.h.

Referenced by btnClicked(), incSteps(), QwtCounter(), and setIncSteps().

int QwtCounter::d_nButtons [private]
 

Definition at line 130 of file qwt_counter.h.

Referenced by numButtons(), and setNumButtons().

QLineEdit* QwtCounter::d_valueEdit [private]
 

Definition at line 127 of file qwt_counter.h.

Referenced by fontChange(), QwtCounter(), showNum(), and sizeHint().


The documentation for this class was generated from the following files:
Generated on Fri Nov 7 14:11:47 2003 for Qwt Developer's Guide by doxygen 1.3.2