Qwt User's Guide
svn
|
#include <qwt_counter.h>
Inherits QwtDoubleRange.
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 | maxValue () const |
double | minValue () const |
int | numButtons () const |
int | pageSize () const |
bool | periodic () const |
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 |
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 * | event | ) | [protected, virtual] |
Handle PolishRequest events
event | Event |
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 fitValue() or 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 | button | ) | const |
button | Button index |
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 * | event | ) | [protected, virtual] |
Handle key events
event | Key event |
double QwtCounter::maxValue | ( | ) | const |
returns the maximum value of the range
Reimplemented from QwtDoubleRange.
double QwtCounter::minValue | ( | ) | const |
returns the minimum value of the range
Reimplemented from QwtDoubleRange.
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.
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 | button, |
int | nSteps | ||
) |
Specify the number of steps by which the value is incremented or decremented when a specified button is pushed.
button | Button index |
nSteps | Number of steps |
void QwtCounter::setMaxValue | ( | double | value | ) |
void QwtCounter::setMinValue | ( | double | value | ) |
Set the minimum value of the range
value | Minimum value |
void QwtCounter::setNumButtons | ( | int | numButtons | ) |
Specify the number of buttons on each side of the label.
numButtons | 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 | value | ) | [virtual] |
Set a new value.
Calls QwtDoubleRange::setValue and does all visual updates.
value | New value |
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 * | event | ) | [protected, virtual] |
Handle wheel events
event | Wheel event |