Qwt User's Guide 5.2.2
|
The Counter Widget. More...
#include <qwt_counter.h>
Public Types | |
enum | Button { Button1, Button2, Button3, ButtonCnt } |
Signals | |
void | buttonReleased (double value) |
void | valueChanged (double value) |
Public Member Functions | |
bool | editable () const |
virtual void | fitValue (double) |
virtual void | incPages (int) |
int | incSteps (QwtCounter::Button btn) const |
virtual void | incValue (int) |
bool | isValid () const |
double | maxVal () const |
double | maxValue () const |
double | minVal () const |
double | minValue () const |
int | numButtons () const |
int | pageSize () const |
bool | periodic () const |
virtual void | polish () |
QwtCounter (QWidget *parent=NULL) | |
void | setEditable (bool) |
void | setIncSteps (QwtCounter::Button btn, int nSteps) |
void | setMaxValue (double m) |
void | setMinValue (double m) |
void | setNumButtons (int n) |
void | setPeriodic (bool tf) |
void | setRange (double vmin, double vmax, double vstep=0.0, int pagesize=1) |
void | setStep (double s) |
void | setStepButton1 (int nSteps) |
void | setStepButton2 (int nSteps) |
void | setStepButton3 (int nSteps) |
void | setValid (bool) |
virtual void | setValue (double) |
virtual QSize | sizeHint () const |
double | step () const |
int | stepButton1 () const |
int | stepButton2 () const |
int | stepButton3 () const |
virtual double | value () const |
virtual | ~QwtCounter () |
Protected Member Functions | |
virtual bool | event (QEvent *) |
double | exactPrevValue () const |
double | exactValue () const |
virtual void | keyPressEvent (QKeyEvent *) |
double | prevValue () const |
virtual void | rangeChange () |
virtual void | stepChange () |
virtual void | wheelEvent (QWheelEvent *) |
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)));
enum QwtCounter::Button |
Button index
QwtCounter::QwtCounter | ( | QWidget * | parent = NULL | ) | [explicit] |
The default number of buttons is set to 2. The default increments are:
parent |
QwtCounter::~QwtCounter | ( | ) | [virtual] |
Destructor.
void QwtCounter::buttonReleased | ( | double | value | ) | [signal] |
This signal is emitted when a button has been released
value | The new value |
bool QwtCounter::editable | ( | ) | const |
returns whether the line edit is edatble. (default is yes)
bool QwtCounter::event | ( | QEvent * | e | ) | [protected, virtual] |
Handle PolishRequest events
double QwtDoubleRange::exactPrevValue | ( | ) | const [protected, inherited] |
Returns the exact previous value.
double QwtDoubleRange::exactValue | ( | ) | const [protected, inherited] |
Returns the exact value.
The exact value is the value which QwtDoubleRange::value would return if the value were not adjusted to the step raster. It differs from the current value only if QwtDoubleRange::fitValue or QwtDoubleRange::incValue have been used before. This function is intended for internal use in derived classes.
void QwtDoubleRange::fitValue | ( | double | x | ) | [virtual, inherited] |
Adjust the value to the closest point in the step raster.
x | value |
new value := x + n * (max. value - min. value)
Reimplemented in QwtAbstractSlider.
void QwtDoubleRange::incPages | ( | int | nPages | ) | [virtual, inherited] |
Increment the value by a specified number of pages.
nPages | Number of pages to increment. A negative number decrements the value. |
int QwtCounter::incSteps | ( | QwtCounter::Button | btn | ) | const |
btn | One of QwtCounter::Button1 , QwtCounter::Button2 , QwtCounter::Button3 |
void QwtDoubleRange::incValue | ( | int | nSteps | ) | [virtual, inherited] |
Increment the value by a specified number of steps.
nSteps | Number of steps to increment |
Reimplemented in QwtAbstractSlider.
bool QwtDoubleRange::isValid | ( | ) | const [inherited] |
Indicates if the value is valid.
Reimplemented in QwtAbstractSlider.
void QwtCounter::keyPressEvent | ( | QKeyEvent * | e | ) | [protected, virtual] |
Handle key events
double QwtCounter::maxVal | ( | ) | const |
returns the maximum value of the range
double QwtDoubleRange::maxValue | ( | ) | const [inherited] |
Returns the value of the second border of the range.
maxValue returns the value which has been specified as the second parameter in QwtDoubleRange::setRange.
double QwtCounter::minVal | ( | ) | const |
returns the minimum value of the range
double QwtDoubleRange::minValue | ( | ) | const [inherited] |
Returns the value at the first border of the range.
minValue returns the value which has been specified as the first parameter in setRange().
int QwtCounter::numButtons | ( | ) | const |
int QwtDoubleRange::pageSize | ( | ) | const [inherited] |
Returns the page size in steps.
bool QwtDoubleRange::periodic | ( | ) | const [inherited] |
Returns true if the range is periodic.
void QwtCounter::polish | ( | ) | [virtual] |
Sets the minimum width for the buttons
double QwtDoubleRange::prevValue | ( | ) | const [protected, inherited] |
Returns the previous value.
void QwtCounter::rangeChange | ( | ) | [protected, virtual] |
Notify change of range.
This function updates the enabled property of all buttons contained in QwtCounter.
Reimplemented from QwtDoubleRange.
void QwtCounter::setEditable | ( | bool | editable | ) |
Allow/disallow the user to manually edit the value.
editable | true enables editing |
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.
btn | One of QwtCounter::Button1 , QwtCounter::Button2 , QwtCounter::Button3 |
nSteps | Number of steps |
void QwtCounter::setMaxValue | ( | double | value | ) |
void QwtCounter::setMinValue | ( | double | value | ) |
void QwtCounter::setNumButtons | ( | int | n | ) |
Specify the number of buttons on each side of the label.
n | Number of buttons |
void QwtDoubleRange::setPeriodic | ( | bool | tf | ) | [inherited] |
Make the range periodic.
When the range is periodic, the value will be set to a point inside the interval such that
point = value + n * width
if the user tries to set a new value which is outside the range. If the range is nonperiodic (the default), values outside the range will be clipped.
tf | true for a periodic range |
void QwtDoubleRange::setRange | ( | double | vmin, |
double | vmax, | ||
double | vstep = 0.0 , |
||
int | pageSize = 1 |
||
) | [inherited] |
Specify range and step size.
vmin | lower boundary of the interval |
vmax | higher boundary of the interval |
vstep | step width |
pageSize | page size in steps |
void QwtCounter::setStep | ( | double | stepSize | ) |
Set the step size
stepSize | Step size |
Reimplemented from QwtDoubleRange.
void QwtCounter::setStepButton1 | ( | int | nSteps | ) |
Set the number of increment steps for button 1
nSteps | Number of steps |
void QwtCounter::setStepButton2 | ( | int | nSteps | ) |
Set the number of increment steps for button 2
nSteps | Number of steps |
void QwtCounter::setStepButton3 | ( | int | nSteps | ) |
Set the number of increment steps for button 3
nSteps | Number of steps |
void QwtDoubleRange::setValid | ( | bool | isValid | ) | [inherited] |
Set the value to be valid/invalid.
Reimplemented in QwtAbstractSlider.
void QwtCounter::setValue | ( | double | v | ) | [virtual] |
Set a new value.
v | new value Calls QwtDoubleRange::setValue and does all visual updates. |
Reimplemented from QwtDoubleRange.
QSize QwtCounter::sizeHint | ( | ) | const [virtual] |
A size hint.
double QwtCounter::step | ( | ) | const |
returns the step size
Reimplemented from QwtDoubleRange.
int QwtCounter::stepButton1 | ( | ) | const |
returns the number of increment steps for button 1
int QwtCounter::stepButton2 | ( | ) | const |
returns the number of increment steps for button 2
int QwtCounter::stepButton3 | ( | ) | const |
returns the number of increment steps for button 3
void QwtDoubleRange::stepChange | ( | ) | [protected, virtual, inherited] |
Notify a change of the step size.
This virtual function is called whenever the step size changes. The default implementation does nothing.
double QwtCounter::value | ( | ) | const [virtual] |
Reimplemented from QwtDoubleRange.
void QwtCounter::valueChanged | ( | double | value | ) | [signal] |
This signal is emitted when the counter's value has changed
value | The new value |
void QwtCounter::wheelEvent | ( | QWheelEvent * | e | ) | [protected, virtual] |
Handle wheel events
e | Wheel event |