QwtCounter - Man Page

Name

QwtCounter ā€”

The Counter Widget. Ā 

Synopsis

#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 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 *)

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

Member Enumeration Documentation

enum QwtCounter::Button Button index

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

QwtCounter::~QwtCounter () [virtual]

Destructor.

Member Function Documentation

void QwtCounter::buttonReleased (doublevalue) [signal] This signal is emitted when a button has been released

Parameters:

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 (doublex) [virtual, inherited]

Adjust the value to the closest point in the step raster. Parameters:

x value

Warning:

The value is clipped when it lies outside the range. When the range is QwtDoubleRange::periodic, it will be mapped to a point in the interval such that

new value := x + n * (max. value - min. value)

with an integer number n.

Reimplemented in QwtAbstractSlider.

void QwtDoubleRange::incPages (intnPages) [virtual, inherited]

Increment the value by a specified number of pages. Parameters:

nPages Number of pages to increment. A negative number decrements the value.

Warning:

The Page size is specified in the constructor.

int QwtCounter::incSteps (QwtCounter::Buttonbtn) const Returns

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

Parameters:

btn One of QwtCounter::Button1, QwtCounter::Button2, QwtCounter::Button3

void QwtDoubleRange::incValue (intnSteps) [virtual, inherited]

Increment the value by a specified number of steps. Parameters:

nSteps Number of steps to increment

Warning:

As a result of this operation, the new value will always be adjusted to the step raster.

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

  • 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)

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.

See also:

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

See also:

setRange()

int QwtCounter::numButtons () const Returns

The number of buttons on each side of the widget.

int QwtDoubleRange::pageSize () const [inherited]

Returns the page size in steps.

bool QwtDoubleRange::periodic () const [inherited]

Returns true if the range is periodic. See also:

setPeriodic()

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

Allow/disallow the user to manually edit the value. Parameters:

editable true enables editing

See also:

editable()

void QwtCounter::setIncSteps (QwtCounter::Buttonbtn, intnSteps) Specify the number of steps by which the value is incremented or decremented when a specified button is pushed.

Parameters:

btn One of QwtCounter::Button1, QwtCounter::Button2, QwtCounter::Button3
nSteps Number of steps

void QwtCounter::setMaxValue (doublevalue) Set the maximum value of the range

Parameters:

value Maximum value

See also:

setMinValue(), maxVal()

void QwtCounter::setMinValue (doublevalue) Set the minimum value of the range

Parameters:

value Minimum value

See also:

setMaxValue(), minVal()

void QwtCounter::setNumButtons (intn)

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

n Number of buttons

void QwtDoubleRange::setPeriodic (booltf) [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 .fi


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.

Parameters:
  tf true for a periodic range

void QwtDoubleRange::setRange (doublevmin, doublevmax, doublevstep = 0.0, intpageSize = 1) [inherited]

Specify range and step size. Parameters:

vmin lower boundary of the interval
vmax higher boundary of the interval
vstep step width
pageSize page size in steps

Warning:
  • A change of the range changes the value if it lies outside the new range. The current value will *not* be adjusted to the new step raster.
  • vmax < vmin is allowed.
  • If the step size is left out or set to zero, it will be set to 1/100 of the interval length.
  • If the step size has an absurd value, it will be corrected to a better one.

void QwtCounter::setStep (doublestepSize) Set the step size

Parameters:

stepSize Step size

See also:

QwtDoubleRange::setStep()

Reimplemented from QwtDoubleRange.

void QwtCounter::setStepButton1 (intnSteps) Set the number of increment steps for button 1

Parameters:

nSteps Number of steps

void QwtCounter::setStepButton2 (intnSteps) Set the number of increment steps for button 2

Parameters:

nSteps Number of steps

void QwtCounter::setStepButton3 (intnSteps) Set the number of increment steps for button 3

Parameters:

nSteps Number of steps

void QwtDoubleRange::setValid (boolisValid) [inherited]

Set the value to be valid/invalid.

Reimplemented in QwtAbstractSlider.

void QwtCounter::setValue (doublev) [virtual]

Set a new value. Parameters:

v new value Calls QwtDoubleRange::setValue and does all visual updates.

See also:

QwtDoubleRange::setValue()

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] Returns

Current value

Reimplemented from QwtDoubleRange.

void QwtCounter::valueChanged (doublevalue) [signal] This signal is emitted when the counter's value has changed

Parameters:

value The new value

void QwtCounter::wheelEvent (QWheelEvent *e) [protected, virtual] Handle wheel events

Parameters:

e Wheel event

Author

Generated automatically by Doxygen for Qwt User's Guide from the source code.

Info

Mon Aug 1 2011 Version 5.2.2 Qwt User's Guide