The Counter Widget. More...
#include <qwt_counter.h>
Classes | |
| class | PrivateData |
Public Types | |
| enum | Button { Button1, Button2, Button3, ButtonCnt } |
| Button index. More... | |
Public Slots | |
| void | setValue (double) |
| Set a new value without adjusting to the step raster. | |
Signals | |
| void | buttonReleased (double value) |
| void | valueChanged (double value) |
Public Member Functions | |
| int | incSteps (QwtCounter::Button btn) const |
| bool | isReadOnly () const |
| bool | isValid () const |
| double | maximum () const |
| double | minimum () const |
| int | numButtons () const |
| QwtCounter (QWidget *parent=NULL) | |
| void | setIncSteps (QwtCounter::Button btn, int nSteps) |
| void | setMaximum (double max) |
| void | setMinimum (double min) |
| void | setNumButtons (int n) |
| void | setRange (double min, double max) |
| Set the minimum and maximum values. | |
| void | setReadOnly (bool) |
| Allow/disallow the user to manually edit the value. | |
| void | setSingleStep (double s) |
| Set the step size of the counter. | |
| void | setStepButton1 (int nSteps) |
| void | setStepButton2 (int nSteps) |
| void | setStepButton3 (int nSteps) |
| void | setValid (bool) |
| void | setWrapping (bool) |
| En/Disable wrapping. | |
| double | singleStep () const |
| virtual QSize | sizeHint () const |
| A size hint. | |
| int | stepButton1 () const |
| int | stepButton2 () const |
| int | stepButton3 () const |
| double | value () const |
| bool | wrapping () const |
| virtual | ~QwtCounter () |
| Destructor. | |
Protected Member Functions | |
| virtual bool | event (QEvent *) |
| virtual void | keyPressEvent (QKeyEvent *) |
| virtual void | wheelEvent (QWheelEvent *) |
Properties | |
| double | maximum |
| double | minimum |
| int | numButtons |
| bool | readOnly |
| double | singleStep |
| int | stepButton1 |
| returns the number of increment steps for button 1 | |
| int | stepButton2 |
| returns the number of increment steps for button 2 | |
| int | stepButton3 |
| returns the number of increment steps for button 3 | |
| double | value |
| bool | wrapping |
Private Slots | |
| void | btnClicked () |
| Button clicked. | |
| void | btnReleased () |
| Button released. | |
| void | textChanged () |
| Set from lineedit. | |
Private Member Functions | |
| void | incrementValue (int numSteps) |
| void | initCounter () |
| void | showNumber (double) |
| void | updateButtons () |
| Update buttons according to the current value. | |
Private Attributes | |
| PrivateData * | d_data |
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. When the wrapping property is set the counter is circular.
The number of steps by which a button increments or decrements the value can be specified using setIncSteps(). The number of buttons can be changed with setNumButtons().
Example:
#include <qwt_counter.h> QwtCounter *counter = new QwtCounter(parent); counter->setRange(0.0, 100.0); // From 0.0 to 100 counter->setSingleStep( 1.0 ); // Step size 1.0 counter->setNumButtons(2); // Two buttons each side counter->setIncSteps(QwtCounter::Button1, 1); // Button 1 increments 1 step counter->setIncSteps(QwtCounter::Button2, 20); // Button 2 increments 20 steps connect(counter, SIGNAL(valueChanged(double)), myClass, SLOT(newValue(double)));
Definition at line 48 of file qwt_counter.h.
| enum QwtCounter::Button |
Button index.
| Button1 |
Button intended for minor steps. |
| Button2 |
Button intended for medium steps. |
| Button3 |
Button intended for large steps. |
| ButtonCnt |
Number of buttons. |
Definition at line 67 of file qwt_counter.h.
| QwtCounter::QwtCounter | ( | QWidget * | parent = NULL | ) | [explicit] |
The counter is initialized with a range is set to [0.0, 1.0] with 0.01 as single step size. The value is invalid.
The default number of buttons is set to 2. The default increments are:
| parent |
Definition at line 63 of file qwt_counter.cpp.
| QwtCounter::~QwtCounter | ( | ) | [virtual] |
Destructor.
Definition at line 126 of file qwt_counter.cpp.
| void QwtCounter::btnClicked | ( | ) | [private, slot] |
Button clicked.
Definition at line 734 of file qwt_counter.cpp.
| void QwtCounter::btnReleased | ( | ) | [private, slot] |
Button released.
Definition at line 747 of file qwt_counter.cpp.
| void QwtCounter::buttonReleased | ( | double | value | ) | [signal] |
This signal is emitted when a button has been released
| value | The new value |
| bool QwtCounter::event | ( | QEvent * | event | ) | [protected, virtual] |
Handle QEvent::PolishRequest events
| event | Event |
Definition at line 484 of file qwt_counter.cpp.
| void QwtCounter::incrementValue | ( | int | numSteps | ) | [private] |
Definition at line 627 of file qwt_counter.cpp.
| int QwtCounter::incSteps | ( | QwtCounter::Button | button | ) | const |
| button | Button index |
Definition at line 415 of file qwt_counter.cpp.
| void QwtCounter::initCounter | ( | ) | [private] |
Definition at line 69 of file qwt_counter.cpp.
| bool QwtCounter::isReadOnly | ( | ) | const |
Definition at line 185 of file qwt_counter.cpp.
| bool QwtCounter::isValid | ( | ) | const |
Definition at line 165 of file qwt_counter.cpp.
| void QwtCounter::keyPressEvent | ( | QKeyEvent * | event | ) | [protected, virtual] |
Handle key events
| event | Key event |
Definition at line 521 of file qwt_counter.cpp.
| double QwtCounter::maximum | ( | ) | const |
| double QwtCounter::minimum | ( | ) | const |
| int QwtCounter::numButtons | ( | ) | const |
| void QwtCounter::setIncSteps | ( | QwtCounter::Button | button, |
| int | numSteps | ||
| ) |
Specify the number of steps by which the value is incremented or decremented when a specified button is pushed.
| button | Button index |
| numSteps | Number of steps |
Definition at line 402 of file qwt_counter.cpp.
| void QwtCounter::setMaximum | ( | double | value | ) |
Set the maximum value of the range
| value | Maximum value |
Definition at line 296 of file qwt_counter.cpp.
| void QwtCounter::setMinimum | ( | double | value | ) |
Set the minimum value of the range
| value | Minimum value |
Definition at line 276 of file qwt_counter.cpp.
| void QwtCounter::setNumButtons | ( | int | numButtons | ) |
Specify the number of buttons on each side of the label
| numButtons | Number of buttons |
Definition at line 361 of file qwt_counter.cpp.
| void QwtCounter::setRange | ( | double | min, |
| double | max | ||
| ) |
Set the minimum and maximum values.
The maximum is adjusted if necessary to ensure that the range remains valid. The value might be modified to be inside of the range.
| min | Minimum value |
| max | Maximum value |
Definition at line 240 of file qwt_counter.cpp.
| void QwtCounter::setReadOnly | ( | bool | on | ) |
Allow/disallow the user to manually edit the value.
| on | True disable editing |
Definition at line 176 of file qwt_counter.cpp.
| void QwtCounter::setSingleStep | ( | double | stepSize | ) |
Set the step size of the counter.
A value <= 0.0 disables stepping
| stepSize | Single step size |
Definition at line 318 of file qwt_counter.cpp.
| void QwtCounter::setStepButton1 | ( | int | nSteps | ) |
Set the number of increment steps for button 1
| nSteps | Number of steps |
Definition at line 428 of file qwt_counter.cpp.
| void QwtCounter::setStepButton2 | ( | int | nSteps | ) |
Set the number of increment steps for button 2
| nSteps | Number of steps |
Definition at line 443 of file qwt_counter.cpp.
| void QwtCounter::setStepButton3 | ( | int | nSteps | ) |
Set the number of increment steps for button 3
| nSteps | Number of steps |
Definition at line 458 of file qwt_counter.cpp.
| void QwtCounter::setValid | ( | bool | on | ) |
Set the counter to be in valid/invalid state
When the counter is set to invalid, no numbers are displayed and the buttons are disabled.
| on | If true the counter will be set as valid |
Definition at line 141 of file qwt_counter.cpp.
| void QwtCounter::setValue | ( | double | value | ) | [slot] |
Set a new value without adjusting to the step raster.
The state of the counter is set to be valid.
| value | New value |
Definition at line 201 of file qwt_counter.cpp.
| void QwtCounter::setWrapping | ( | bool | on | ) |
En/Disable wrapping.
If wrapping is true stepping up from maximum() value will take you to the minimum() value and vice versa.
| on | En/Disable wrapping |
Definition at line 341 of file qwt_counter.cpp.
| void QwtCounter::showNumber | ( | double | number | ) | [private] |
| double QwtCounter::singleStep | ( | ) | const |
| QSize QwtCounter::sizeHint | ( | ) | const [virtual] |
A size hint.
Definition at line 753 of file qwt_counter.cpp.
| int QwtCounter::stepButton1 | ( | ) | const |
| int QwtCounter::stepButton2 | ( | ) | const |
| int QwtCounter::stepButton3 | ( | ) | const |
| void QwtCounter::textChanged | ( | ) | [private, slot] |
Set from lineedit.
Definition at line 470 of file qwt_counter.cpp.
| void QwtCounter::updateButtons | ( | ) | [private] |
Update buttons according to the current value.
When the QwtCounter under- or over-flows, the focus is set to the smallest up- or down-button and counting is disabled.
Counting is re-enabled on a button release event (mouse or space bar).
Definition at line 696 of file qwt_counter.cpp.
| double QwtCounter::value | ( | ) | const |
| 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] |
| bool QwtCounter::wrapping | ( | ) | const |
PrivateData* QwtCounter::d_data [private] |
Definition at line 157 of file qwt_counter.h.
double QwtCounter::maximum [read, write] |
Definition at line 54 of file qwt_counter.h.
double QwtCounter::minimum [read, write] |
Definition at line 53 of file qwt_counter.h.
int QwtCounter::numButtons [read, write] |
Definition at line 57 of file qwt_counter.h.
bool QwtCounter::readOnly [read, write] |
Definition at line 62 of file qwt_counter.h.
double QwtCounter::singleStep [read, write] |
int QwtCounter::stepButton1 [read, write] |
returns the number of increment steps for button 1
Definition at line 58 of file qwt_counter.h.
int QwtCounter::stepButton2 [read, write] |
returns the number of increment steps for button 2
Definition at line 59 of file qwt_counter.h.
int QwtCounter::stepButton3 [read, write] |
returns the number of increment steps for button 3
Definition at line 60 of file qwt_counter.h.
double QwtCounter::value [read, write] |
Definition at line 52 of file qwt_counter.h.
bool QwtCounter::wrapping [read, write] |
Definition at line 63 of file qwt_counter.h.