Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

FloatSpinBox Class Reference

A floating point spinner class for Qt which also supports enhanced munging. More...

#include <floatspinbox.h>

Inheritance diagram for FloatSpinBox::

List of all members.

Public Slots

void setDoubleRange (double min, double max)
void setDoubleMinValue (double min)
void setDoubleMaxValue (double max)
void setDoubleLineStep (double step)
void setDoubleValue (double val)

Signals

void valueChanged (double)

Public Methods

 FloatSpinBox (QWidget *parent=0, const char *name=0)
 FloatSpinBox (double minValue, double maxValue, double step=0.1, QWidget *parent=0, const char *name=0)
 ~FloatSpinBox ()
void stepUp ()
void stepDown ()
void stepUp (int howMany)
void stepDown (int howMany)
void setCursorWarping (bool onOff)
bool cursorWarping () const
void setDoubleFormat (char f='g', int prec=4)
void setDoubleMinValue (const QString &min)
void setDoubleMaxValue (const QString &max)
void setDoubleLineStep (const QString &step)
void setDoubleValue (const QString &val)
QString doubleMinValueStr () const
QString doubleMaxValueStr () const
QString doubleLineStepStr () const
QString doubleValueStr () const
double doubleMinValue () const
double doubleMaxValue () const
double doubleLineStep () const
double doubleValue () const

Protected Methods

int mapTextToValue (bool *)
QString mapValueToText (int v)
void valueChange ()
void mousePressEvent (QMouseEvent *)
void mouseReleaseEvent (QMouseEvent *)
void mouseMoveEvent (QMouseEvent *)
void keyPressEvent (QKeyEvent *)
bool eventFilter (QObject *, QEvent *)

Detailed Description

A floating point spinner class for Qt which also supports enhanced munging.

Author:
William V. Baxter III
Date:
October 25, 2001

Works just like a normal QSpinBox, but

There is also a Qt ".cw" Custom Widget file that can be imported into QDesigner, which provides a complete description of the widget. QDesigner 2.3.0 doesn't allow for setting floating point properties (silly!), so I've added some string properties for getting and setting the various values which do appear in QDesigner, and can be used to set the floating point range, step size, and value.

Note:
The underlying values are still stored in integers. So if you type in an arbitrary floating point value it will be rounded to the nearest whole value in the underlying representation. This should be sufficient for most applications, really, but I could probably fix it by keeping track of a double floating point offset to use when converting back and forth between the int and double representations. An exercise for the reader, perhaps.


Constructor & Destructor Documentation

FloatSpinBox::FloatSpinBox QWidget *   parent = 0,
const char *   name = 0
 

Constructs a spin box with the default range and step value.

FloatSpinBox::FloatSpinBox double   minValue,
double   maxValue,
double   step = 0.1,
QWidget *   parent = 0,
const char *   name = 0
 

Constructs a spin box with the specified range and step value. The range is inclusive.

Note:
The minValue and \maxValue are rounded to the nearest integer multiple of step.


Member Function Documentation

bool FloatSpinBox::cursorWarping   const
 

Returns whether the cursor is warped during munging when it gets to the edge of the screen. Default value is true;

double FloatSpinBox::doubleLineStep   const
 

Returns the current line step of the spinner as a double. This is the amount the spinner will be incremented in response to clicks of the up and down buttons and in response to the up and down arrow keys. Analogous to QSpinBox::lineStep() for the standard QSpinBox.

QString FloatSpinBox::doubleLineStepStr   const
 

Returns the floating point line step as a string.

This is here because QDesigner 2.3.0 won't allow a user to set properties that are doubles, just strings or ints or the like. The line step property appears in QDesigner as lineStepStr. Use that to set the initial line step of the spinner.

double FloatSpinBox::doubleMaxValue   const
 

Returns the maximum value of the spinner as a double. Analogous to QSpinBox::maxValue() for the standard QSpinBox.

QString FloatSpinBox::doubleMaxValueStr   const
 

Returns the maximum value of the spinner allowed as a string.

This is here because QDesigner 2.3.0 won't allow a user to set properties that are doubles, just strings or ints or the like. The max property appears in QDesigner as maxValueStr. Use that to set the initial max value of the spinner.

double FloatSpinBox::doubleMinValue   const
 

Returns the minimum value of the spinner as a double. Analogous to QSpinBox::minValue() for the standard QSpinBox.

QString FloatSpinBox::doubleMinValueStr   const
 

Returns the minimum value of the spinner allowed as a string.

This is here because QDesigner 2.3.0 won't allow a user to set properties that are doubles, just strings or ints or the like. The min property appears in QDesigner as minValueStr. Use that to set the initial min value of the spinner.

double FloatSpinBox::doubleValue   const
 

Returns the current value of the spinner as a double. Analogous to QSpinBox::value() for the standard QSpinBox.

QString FloatSpinBox::doubleValueStr   const
 

Return the floating point value of the spinner as a string.

This is here because QDesigner 2.3.0 won't allow a user to set properties that are doubles, just strings or ints or the like. The value property appears in QDesigner as valueStr. Use that to set the initial value of the spinner.

bool FloatSpinBox::eventFilter QObject *   o,
QEvent *   ee
[protected]
 

Reimplemented for internal reasons; the API is not affected.

void FloatSpinBox::keyPressEvent QKeyEvent *   e [protected]
 

Reimplemented for internal reasons; the API is not affected.

int FloatSpinBox::mapTextToValue bool *   ok [protected]
 

Reimplemented for internal reasons; the API is not affected.

QString FloatSpinBox::mapValueToText int   v [protected]
 

Reimplemented for internal reasons; the API is not affected.

void FloatSpinBox::mouseMoveEvent QMouseEvent *   e [protected]
 

Reimplemented for internal reasons; the API is not affected.

void FloatSpinBox::mousePressEvent QMouseEvent *   e [protected]
 

Reimplemented for internal reasons; the API is not affected.

void FloatSpinBox::mouseReleaseEvent QMouseEvent *   e [protected]
 

Reimplemented for internal reasons; the API is not affected.

void FloatSpinBox::setCursorWarping bool   onOff
 

Sets whether the cursor will be warped during munging when it gets to the edge of the screen. Default value is true;

void FloatSpinBox::setDoubleFormat char   f = 'g',
int   prec = 4
 

Sets the floating point output format for the spinner to use. These parameters are passed to QString::setNum() in order to convert the floating point value to a string.

void FloatSpinBox::setDoubleLineStep double   step [slot]
 

Sets the current floating point line step of the spinner. This is the amount the spinner will be incremented in response to clicks of the up and down buttons and in response to the up and down arrow keys. Analogous to QSpinBox::setLineStep() for the standard QSpinBox.

Note:
Calling this will cause the minimum, maximum and current values of the spinner to be rounded to the nearest integer multiple of step.

void FloatSpinBox::setDoubleLineStep const QString &   step
 

Sets the floating point line step using a string.

This is here because QDesigner 2.3.0 won't allow a user to set properties that are doubles, just strings or ints or the like. The line step property appears in QDesigner as lineStepStr. Use that to set the initial line step of the spinner.

void FloatSpinBox::setDoubleMaxValue double   max [slot]
 

Set the maximum allowable floating point value for the spinner. Analogous to QSpinBox::setMaxValue() for the standard QSpinBox.

Note:
max is rounded to the nearest integer multiple of the current line step as given by doubleLineStep().

void FloatSpinBox::setDoubleMaxValue const QString &   max
 

Sets the maximum value of the spinner to be allowed using a string.

This is here because QDesigner 2.3.0 won't allow a user to set properties that are doubles, just strings or ints or the like. The max property appears in QDesigner as maxValueStr. Use that to set the initial max value of the spinner.

void FloatSpinBox::setDoubleMinValue double   min [slot]
 

Set the minimum allowable floating point value for the spinner. Analogous to QSpinBox::setMinValue() for the standard QSpinBox.

Note:
min is rounded to the nearest integer multiple of the current line step as given by doubleLineStep().

void FloatSpinBox::setDoubleMinValue const QString &   min
 

Sets the minimum value of the spinner to be allowed using a string.

This is here because QDesigner 2.3.0 won't allow a user to set properties that are doubles, just strings or ints or the like. The min property appears in QDesigner as minValueStr. Use that to set the initial min value of the spinner.

void FloatSpinBox::setDoubleRange double   min,
double   max
[slot]
 

Sets the floating point range of allowed values for the spin box.

Note:
The min and \max are rounded to the nearest integer multiples of the current line step as given by doubleLineStep().

void FloatSpinBox::setDoubleValue double   value [slot]
 

Sets the current value of the spinner as a double. Analogous to QSpinBox::setValue() for the standard QSpinBox.

Note:
value is rounded to the nearest integer multiple of the current line step as given by doubleLineStep().

void FloatSpinBox::setDoubleValue const QString &   val
 

Sets the floating point value of the spinner using a string.

This is here because QDesigner 2.3.0 won't allow a user to set properties that are doubles, just strings or ints or the like. The value property appears in QDesigner as valueStr. Use that to set the initial value of the spinner.

void FloatSpinBox::stepDown int   howMany
 

Steps the value down by howMany steps. Equivalent to calling stepDown() howMany times, but is more efficient.

Note:
If howMany is negative, this is equivalent to calling stepUp(int) with a positive value.

void FloatSpinBox::stepDown   [inline]
 

Reimplemented for internal reasons; the API is not affected.

void FloatSpinBox::stepUp int   howMany
 

Steps the value up by howMany steps. Equivalent to calling stepUp() howMany times, but is more efficient.

Note:
If howMany is negative, this is equivalent to calling stepDown(int) with a positive value.

void FloatSpinBox::stepUp   [inline]
 

Reimplemented for internal reasons; the API is not affected.

void FloatSpinBox::valueChange   [protected]
 

Reimplemented for internal reasons; the API is not affected.


The documentation for this class was generated from the following files:
Generated at Thu Oct 25 12:56:38 2001 for FloatSpinBox by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001