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 63 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=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 |
virtual bool | eventFilter (QObject *, QEvent *) |
Protected Member Functions | |
virtual void | rangeChange () |
virtual void | fontChange (const QFont &f) |
|
Button index Definition at line 81 of file qwt_counter.h. |
|
The default number of buttons is set to 2. The default increments are:
References setNumButtons(), QwtDblRange::setRange(), and setValue(). |
|
This signal is emitted when a button has been released
|
|
Keep track of key press and release events. Definition at line 78 of file qwt_counter.cpp. |
|
Notify change of font. This function updates the fonts of all widgets contained in QwtCounter.
|
|
|
|
returns the maximum value of the range Definition at line 94 of file qwt_counter.h. References QwtDblRange::maxValue(). |
|
returns the minimum value of the range Definition at line 90 of file qwt_counter.h. References QwtDblRange::minValue(). |
|
|
|
Notify change of range. This function updates the enabled property of all buttons contained in QwtCounter. Reimplemented from QwtDblRange. Definition at line 296 of file qwt_counter.cpp. |
|
Specify the number of steps by which the value is incremented or decremented when a specified button is pushed.
|
|
sets the maximum value of the range Definition at line 96 of file qwt_counter.h. References QwtDblRange::minValue(), QwtDblRange::setRange(), and QwtDblRange::step(). |
|
sets the minimum value of the range Definition at line 92 of file qwt_counter.h. References QwtDblRange::maxValue(), QwtDblRange::setRange(), and QwtDblRange::step(). |
|
Specify the number of buttons on each side of the label.
Referenced by QwtCounter(). |
|
sets the step size
Reimplemented from QwtDblRange. Definition at line 88 of file qwt_counter.h. References QwtDblRange::setStep(). |
|
set the number of increment steps for button 1 Definition at line 98 of file qwt_counter.h. |
|
set the number of increment steps for button 2 Definition at line 102 of file qwt_counter.h. |
|
set the number of increment steps for button 3 Definition at line 106 of file qwt_counter.h. |
|
Set a new value.
Reimplemented from QwtDblRange. Definition at line 142 of file qwt_counter.cpp. References QwtDblRange::setValue(), and value(). Referenced by QwtCounter(). |
|
A size hint. Definition at line 315 of file qwt_counter.cpp. References step(). |
|
Preferred/Fixed. Definition at line 350 of file qwt_counter.cpp. |
|
returns the step size
Reimplemented from QwtDblRange. Definition at line 86 of file qwt_counter.h. References QwtDblRange::step(). Referenced by sizeHint(). |
|
returns the number of increment steps for button 1 Definition at line 100 of file qwt_counter.h. |
|
returns the number of increment steps for button 2 Definition at line 104 of file qwt_counter.h. |
|
returns the number of increment steps for button 3 Definition at line 108 of file qwt_counter.h. |
|
Returns the current value.
Reimplemented from QwtDblRange. Definition at line 109 of file qwt_counter.h. References QwtDblRange::value(). Referenced by setValue(). |
|
This signal is emitted when the counter's value has changed
|