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

QwtCounter Class Reference

Inheritance diagram for QwtCounter:

Inheritance graph
[legend]
Collaboration diagram for QwtCounter:

Collaboration graph
[legend]
List of all members.

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().

Holding the space bar down with focus on a button is the fastest method to step through the counter values. When the counter underflows/overflows, the focus is set to the smallest up/down button and counting is disabled. Counting is re-enabled on a button release event (mouse or space bar).

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 60 of file qwt_counter.h.

Public Types

enum  Button {
  Button1,
  Button2,
  Button3,
  ButtonCnt
}

Signals

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

Public Member Functions

 QwtCounter (QWidget *parent=NULL)
virtual ~QwtCounter ()
bool editable () const
void setEditable (bool)
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 QSize sizeHint () const
virtual void polish ()
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

Protected Member Functions

virtual bool event (QEvent *)
virtual void wheelEvent (QWheelEvent *)
virtual void keyPressEvent (QKeyEvent *)
virtual void rangeChange ()


Member Enumeration Documentation

enum QwtCounter::Button
 

Button index

Definition at line 79 of file qwt_counter.h.


Constructor & Destructor Documentation

QwtCounter::QwtCounter QWidget *  parent = NULL  )  [explicit]
 

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 

Definition at line 50 of file qwt_counter.cpp.

References setNumButtons(), QwtDoubleRange::setRange(), and setValue().


Member Function Documentation

void QwtCounter::buttonReleased double  value  )  [signal]
 

This signal is emitted when a button has been released

Parameters:
value The new value

bool QwtCounter::editable  )  const
 

returns whether the line edit is edatble. (default is yes)

Definition at line 176 of file qwt_counter.cpp.

bool QwtCounter::event QEvent *  e  )  [protected, virtual]
 

Handle PolishRequest events

Definition at line 184 of file qwt_counter.cpp.

References polish().

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 345 of file qwt_counter.cpp.

Referenced by stepButton1(), stepButton2(), and stepButton3().

void QwtCounter::keyPressEvent QKeyEvent *  e  )  [protected, virtual]
 

Handles key events

  • Ctrl + Qt::Key_Home Step to minValue()
  • Ctrl + Qt::Key_End Step to maxValue()
  • Qt::Key_Up Increment by incSteps(QwtCounter::Button1)
  • Qt::Key_Down Decrement by incSteps(QwtCounter::Button1)
  • Qt::Key_PageUp Increment by incSteps(QwtCounter::Button2)
  • Qt::Key_PageDown Decrement by incSteps(QwtCounter::Button2)
  • Shift + Qt::Key_PageUp Increment by incSteps(QwtCounter::Button3)
  • Shift + Qt::Key_PageDown Decrement by incSteps(QwtCounter::Button3)

Definition at line 214 of file qwt_counter.cpp.

References QwtDoubleRange::incValue(), QwtDoubleRange::maxValue(), QwtDoubleRange::minValue(), and setValue().

double QwtCounter::maxVal  )  const
 

returns the maximum value of the range

Definition at line 552 of file qwt_counter.cpp.

References QwtDoubleRange::maxValue().

double QwtCounter::minVal  )  const
 

returns the minimum value of the range

Definition at line 540 of file qwt_counter.cpp.

References QwtDoubleRange::minValue().

int QwtCounter::numButtons  )  const
 

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

Definition at line 444 of file qwt_counter.cpp.

void QwtCounter::polish  )  [virtual]
 

Sets the minimum width for the buttons

Definition at line 129 of file qwt_counter.cpp.

Referenced by event().

void QwtCounter::rangeChange  )  [protected, virtual]
 

Notify change of range.

This function updates the enabled property of all buttons contained in QwtCounter.

Reimplemented from QwtDoubleRange.

Definition at line 485 of file qwt_counter.cpp.

void QwtCounter::setEditable bool  editable  ) 
 

Allow/disallow the user to manually edit the value.

Parameters:
editable true enables editing
See also:
editable()

Definition at line 163 of file qwt_counter.cpp.

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 333 of file qwt_counter.cpp.

Referenced by setStepButton1(), setStepButton2(), and setStepButton3().

void QwtCounter::setMaxValue double  m  ) 
 

sets the maximum value of the range

Definition at line 558 of file qwt_counter.cpp.

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

void QwtCounter::setMinValue double  m  ) 
 

sets the minimum value of the range

Definition at line 546 of file qwt_counter.cpp.

References QwtDoubleRange::maxValue(), QwtDoubleRange::setRange(), and 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 419 of file qwt_counter.cpp.

Referenced by QwtCounter().

void QwtCounter::setStep double  s  ) 
 

sets the step size

Reimplemented from QwtDoubleRange.

Definition at line 534 of file qwt_counter.cpp.

References QwtDoubleRange::setStep().

void QwtCounter::setStepButton1 int  nSteps  ) 
 

set the number of increment steps for button 1

Definition at line 564 of file qwt_counter.cpp.

References setIncSteps().

void QwtCounter::setStepButton2 int  nSteps  ) 
 

set the number of increment steps for button 2

Definition at line 576 of file qwt_counter.cpp.

References setIncSteps().

void QwtCounter::setStepButton3 int  nSteps  ) 
 

set the number of increment steps for button 3

Definition at line 588 of file qwt_counter.cpp.

References setIncSteps().

void QwtCounter::setValue double  v  )  [virtual]
 

Set a new value.

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

Reimplemented from QwtDoubleRange.

Definition at line 360 of file qwt_counter.cpp.

References QwtDoubleRange::setValue(), and value().

Referenced by keyPressEvent(), and QwtCounter().

QSize QwtCounter::sizeHint  )  const [virtual]
 

A size hint.

Definition at line 491 of file qwt_counter.cpp.

References QwtDoubleRange::maxValue(), QwtDoubleRange::minValue(), qwtMin, and step().

double QwtCounter::step  )  const
 

returns the step size

Reimplemented from QwtDoubleRange.

Definition at line 528 of file qwt_counter.cpp.

References QwtDoubleRange::step().

Referenced by setMaxValue(), setMinValue(), and sizeHint().

int QwtCounter::stepButton1  )  const
 

returns the number of increment steps for button 1

Definition at line 570 of file qwt_counter.cpp.

References incSteps().

int QwtCounter::stepButton2  )  const
 

returns the number of increment steps for button 2

Definition at line 582 of file qwt_counter.cpp.

References incSteps().

int QwtCounter::stepButton3  )  const
 

returns the number of increment steps for button 3

Definition at line 594 of file qwt_counter.cpp.

References incSteps().

double QwtCounter::value  )  const [virtual]
 

Returns the current value.

Reimplemented from QwtDoubleRange.

Definition at line 599 of file qwt_counter.cpp.

References QwtDoubleRange::value().

Referenced by setValue().

void QwtCounter::valueChanged double  value  )  [signal]
 

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

Parameters:
value The new value


Generated on Mon Jan 30 22:16:48 2006 for Qwt User's Guide by  doxygen 1.4.4