Qwt User's Guide 6.0.2

- Main Page
- Related Pages
- Classes

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

Public Types | Signals | Public Member Functions | Protected Member Functions
QwtCounter Class Reference

`#include <qwt_counter.h>`

Inheritance diagram for QwtCounter:
[legend]

List of all members.

## Public Types

enum | Button { Button1, Button2, Button3, ButtonCnt }

## Signals

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

## Public Member Functions

| QwtCounter (QWidget *parent=NULL)
virtual | ~QwtCounter ()
bool | editable () const
int | incSteps (QwtCounter::Button btn) const
double | maxValue () const
double | minValue () const
int | numButtons () const
void | setEditable (bool)
void | setIncSteps (QwtCounter::Button btn, int nSteps)
void | setMaxValue (double m)
void | setMinValue (double m)
void | setNumButtons (int n)
void | setStep (double s)
void | setStepButton1 (int nSteps)
void | setStepButton2 (int nSteps)
void | setStepButton3 (int nSteps)
virtual void | setValue (double)
virtual QSize | sizeHint () const
double | step () const
int | stepButton1 () const
int | stepButton2 () const
int | stepButton3 () const
virtual double | value () const
Public Member Functions inherited from QwtDoubleRange
| QwtDoubleRange ()
virtual | ~QwtDoubleRange ()
virtual void | fitValue (double)
virtual void | incPages (int)
virtual void | incValue (int)
bool | isValid () const
int | pageSize () const
bool | periodic () const
void | setPeriodic (bool tf)
void | setRange (double vmin, double vmax, double vstep=0.0, int pagesize=1)
void | setValid (bool)

## Protected Member Functions

virtual bool | event (QEvent *)
virtual void | keyPressEvent (QKeyEvent *)
virtual void | rangeChange ()
virtual void | wheelEvent (QWheelEvent *)
Protected Member Functions inherited from QwtDoubleRange
double | exactPrevValue () const
double | exactValue () const
double | prevValue () const
virtual void | stepChange ()

## Detailed Description

The Counter Widget.

A Counter consists of a lineEdit displaying a number and one ore more (up to three) push buttons on each side of the lineEdit 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 setRange(). 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, 1.0); // From 0.0 to 100, step 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)), my_class, 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 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 PolishRequest events

Parameters:

  event | 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()

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

protectedvirtual

Handle key events

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

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

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

void QwtCounter::rangeChange | ( |  | ) |

protectedvirtual

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.

Parameters:

  editable | true enables editing

See also:
  editable()

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.

Parameters:

  button | Button index
  nSteps | Number of steps

See also:
  incSteps()

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

Set the maximum value of the range

Parameters:

  value | Maximum value

See also:
  setMinValue(), maxVal()

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

Set the minimum value of the range

Parameters:

  value | Minimum value

See also:
  setMaxValue(), minValue()

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

Specify the number of buttons on each side of the label.

Parameters:

  numButtons | Number of buttons

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

Set the step size

Parameters:

  stepSize | Step size

See also:
  QwtDoubleRange::setStep()

Reimplemented from QwtDoubleRange.

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::setValue | ( | double | value | ) |

virtual

Set a new value.

Calls QwtDoubleRange::setValue and does all visual updates.

Parameters:

  value | New value

See also:
  QwtDoubleRange::setValue()

Reimplemented from QwtDoubleRange.

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

virtual

Returns:
  Current value

Reimplemented from QwtDoubleRange.

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