Qwt User's Guide 6.1.3

- Main Page
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Types | Public Slots | Signals | Public Member Functions | Protected Member Functions | List of all members
QwtCounter Class Reference

The Counter Widget. More...

`#include <qwt_counter.h>`

Inheritance diagram for QwtCounter:
[legend]

## 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. More...

## Signals
void | buttonReleased (double value)
void | valueChanged (double value)

## Public Member Functions
| QwtCounter (QWidget *parent=NULL)
virtual | ~QwtCounter ()
| Destructor.
void | setValid (bool)
bool | isValid () const
void | setWrapping (bool)
| En/Disable wrapping. More...
bool | wrapping () const
bool | isReadOnly () const
void | setReadOnly (bool)
| Allow/disallow the user to manually edit the value. More...
void | setNumButtons (int n)
int | numButtons () const
void | setIncSteps (QwtCounter::Button btn, int nSteps)
int | incSteps (QwtCounter::Button btn) const
virtual QSize | sizeHint () const
| A size hint.
double | singleStep () const
void | setSingleStep (double s)
| Set the step size of the counter. More...
void | setRange (double min, double max)
| Set the minimum and maximum values. More...
double | minimum () const
void | setMinimum (double min)
double | maximum () const
void | setMaximum (double max)
void | setStepButton1 (int nSteps)
int | stepButton1 () const
| returns the number of increment steps for button 1
void | setStepButton2 (int nSteps)
int | stepButton2 () const
| returns the number of increment steps for button 2
void | setStepButton3 (int nSteps)
int | stepButton3 () const
| returns the number of increment steps for button 3
double | value () const

## Protected Member Functions
virtual bool | event (QEvent *)
virtual void | wheelEvent (QWheelEvent *)
virtual void | keyPressEvent (QKeyEvent *)

## 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. 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)));

## Member Enumeration Documentation

enum QwtCounter::Button

Button index.

Enumerator
Button1 | Button intended for minor steps.
Button2 | Button intended for medium steps.
Button3 | Button intended for large steps.
ButtonCnt | Number of buttons.

## Constructor & Destructor Documentation

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:

- Button 1: 1 step
- Button 2: 10 steps
- Button 3: 100 steps

Parameters

  parent |

## 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::event | ( | QEvent * | event | ) |
| protectedvirtual

Handle QEvent::PolishRequest events

Parameters

  event | Event

Returns
  see QWidget::event()

int QwtCounter::incSteps | ( | QwtCounter::Button | button | ) | const

Returns
  The number of steps by which a specified button increments the value or 0 if the button is invalid.

Parameters

  button | Button index

See also
  setIncSteps()

bool QwtCounter::isReadOnly | ( |  | ) | const

Returns
  True, when the line line edit is read only. (default is no)

See also
  setReadOnly()

bool QwtCounter::isValid | ( |  | ) | const

Returns
  True, if the value is valid

See also
  setValid(), setValue()

void QwtCounter::keyPressEvent | ( | QKeyEvent * | event | ) |
| protectedvirtual

Handle key events

- Ctrl + Qt::Key_Home
  Step to minimum()
- Ctrl + Qt::Key_End
  Step to maximum()
- 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)

Parameters

  event | Key event

double QwtCounter::maximum | ( |  | ) | const

Returns
  The maximum of the range

See also
  setRange(), setMaximum(), minimum()

double QwtCounter::minimum | ( |  | ) | const

Returns
  The minimum of the range

See also
  setRange(), setMinimum(), maximum()

int QwtCounter::numButtons | ( |  | ) | const

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

See also
  setNumButtons()

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.

Parameters

  button | Button index
  numSteps | Number of steps

See also
  incSteps()

void QwtCounter::setMaximum | ( | double | value | ) |

Set the maximum value of the range

Parameters

  value | Maximum value

See also
  setRange(), setMinimum(), maximum()

void QwtCounter::setMinimum | ( | double | value | ) |

Set the minimum value of the range

Parameters

  value | Minimum value

See also
  setRange(), setMaximum(), minimum()

Note
  The maximum is adjusted if necessary to ensure that the range remains valid.

void QwtCounter::setNumButtons | ( | int | numButtons | ) |

Specify the number of buttons on each side of the label

Parameters

  numButtons | Number of buttons

See also
  numButtons()

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.

Parameters

  min | Minimum value
  max | Maximum value

See also
  minimum(), maximum()

void QwtCounter::setReadOnly | ( | bool | on | ) |

Allow/disallow the user to manually edit the value.

Parameters

  on | True disable editing

See also
  isReadOnly()

void QwtCounter::setSingleStep | ( | double | stepSize | ) |

Set the step size of the counter.

A value <= 0.0 disables stepping

Parameters

  stepSize | Single step size

See also
  singleStep()

void QwtCounter::setStepButton1 | ( | int | nSteps | ) |

Set the number of increment steps for button 1

Parameters

  nSteps | Number of steps

void QwtCounter::setStepButton2 | ( | int | nSteps | ) |

Set the number of increment steps for button 2

Parameters

  nSteps | Number of steps

void QwtCounter::setStepButton3 | ( | int | nSteps | ) |

Set the number of increment steps for button 3

Parameters

  nSteps | Number of steps

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.

Parameters

  on | If true the counter will be set as valid

See also
  setValue(), isValid()

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.

Parameters

  value | New value

See also
  isValid(), value(), valueChanged()

Warning
  The value is clipped when it lies outside the range.

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.

Parameters

  on | En/Disable wrapping

See also
  wrapping()

double QwtCounter::singleStep | ( |  | ) | const

Returns
  Single step size

See also
  setSingleStep()

double QwtCounter::value | ( |  | ) | const

Returns
  Current value of the counter

See also
  setValue(), valueChanged()

void QwtCounter::valueChanged | ( | double | value | ) |
| signal

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

Parameters

  value | The new value

void QwtCounter::wheelEvent | ( | QWheelEvent * | event | ) |
| protectedvirtual

Handle wheel events

Parameters

  event | Wheel event

bool QwtCounter::wrapping | ( |  | ) | const

Returns
  True, when wrapping is set

See also
  setWrapping()