itom
Loading...
Searching...
No Matches
DoubleSpinBox Class Reference

Custom SpinBox The DoubleSpinBox internally uses a QDoubleSpinBox while it retain controls over it. More...

#include <doubleSpinBox.h>

Inheritance diagram for DoubleSpinBox:

Public Types

enum  SetMode { SetAlways , SetIfDifferent }
 
enum  DecimalsOption {
  FixedDecimals = 0x000 , DecimalsByShortcuts = 0x001 , DecimalsByKey = 0x002 , DecimalsByValue = 0x004 ,
  InsertDecimals = 0x008 , ReplaceDecimals = 0x010 , DecimalsAsMax = 0x020 , DecimalsAsMin = 0x040 ,
  DecimalPointAlwaysVisible = 0x080
}
 
enum  SizeHintPolicy { SizeHintByMinMax , SizeHintByValue }
 
typedef QWidget Superclass
 

Public Slots

void setValue (double value)
 
void setValueIfDifferent (double value)
 
void setValueAlways (double value)
 
void stepUp ()
 
void stepDown ()
 
void setDecimals (int decimal)
 

Signals

void valueChanged (double)
 
void valueChanged (const QString &)
 
void editingFinished ()
 
void decimalsChanged (int)
 Signal emitted when the decimals of the displayed are changed.
 

Public Member Functions

 DoubleSpinBox (QWidget *parent=0)
 
 DoubleSpinBox (DoubleSpinBox::SetMode mode, QWidget *parent=0)
 
double value () const
 
double displayedValue () const
 
void setDisplayedValue (double displayValue)
 
QString text () const
 
QString cleanText () const
 
Qt::Alignment alignment () const
 Set/Get the spinbox alignment.
 
void setAlignment (Qt::Alignment flag)
 
void setFrame (bool frame)
 Set/Get the frame.
 
bool hasFrame () const
 
QString prefix () const
 
void setPrefix (const QString &prefix)
 
QString suffix () const
 
void setSuffix (const QString &suffix)
 
double singleStep () const
 
void setSingleStep (double value)
 
double minimum () const
 Set/Get the range of the spinbox. Default range is [0.0, 9.9].
 
void setMinimum (double min)
 
double maximum () const
 
void setMaximum (double max)
 
void setRange (double min, double max)
 
int decimals () const
 
double round (double value) const
 
QDoubleSpinBox * spinBox () const
 
QLineEdit * lineEdit () const
 
DoubleSpinBox::SetMode setMode () const
 Set the spinbox mode when using a set*() method. /.
 
void setSetMode (SetMode mode)
 
DoubleSpinBox::DecimalsOptions decimalsOption ()
 
void setDecimalsOption (DoubleSpinBox::DecimalsOptions option)
 
void setInvertedControls (bool invertedControls)
 
bool invertedControls () const
 
void setSizeHintPolicy (SizeHintPolicy newSizeHintPolicy)
 
SizeHintPolicy sizeHintPolicy () const
 
void setValueProxy (ValueProxy *proxy)
 
ValueProxyvalueProxy () const
 
virtual QSize sizeHint () const
 
virtual QSize minimumSizeHint () const
 
void setKeyboardTracking (bool kt)
 
bool keyboardTracking () const
 

Protected Member Functions

virtual void keyPressEvent (QKeyEvent *event)
 Reimplemented to support shortcuts.
 
virtual bool eventFilter (QObject *obj, QEvent *event)
 Reimplemented to support shortcuts on the double spinbox.
 

Protected Attributes

DoubleSpinBoxPrivate *const d_ptr
 

Properties

Qt::Alignment alignment
 
bool frame
 
QString prefix
 
QString suffix
 
QString cleanText
 
int decimals
 
DecimalsOptions decimalsOption
 
double minimum
 
double maximum
 
double singleStep
 
double value
 
SetMode setMode
 
bool invertedControls
 
SizeHintPolicy sizeHintPolicy
 
bool keyboardTracking
 This property wraps the keyboardTracking property of the underlying spinbox.
 

Private Member Functions

 Q_DECLARE_PRIVATE (DoubleSpinBox)
 
 Q_DISABLE_COPY (DoubleSpinBox)
 

Friends

class CoordinatesWidgetPrivate
 

Detailed Description

Custom SpinBox The DoubleSpinBox internally uses a QDoubleSpinBox while it retain controls over it.

See also
DoubleSlider, SliderWidget, RangeSlider

Member Enumeration Documentation

◆ DecimalsOption

DecimalsOption enums the input style of the spinbox decimals. Default option is DecimalsByShortcuts.

See also
decimals(), currentDecimals()
Enumerator
FixedDecimals 

Behaves just like a QDoubleSpinBox. The maximum number of decimals allowed is given by decimals().

DecimalsByShortcuts 

When the spinbox has focus, entering the shortcut "CTRL +" adds decimals to the current number of decimals. "CTRL -" decreases the number of decimals and "CTRL 0" returns it to its original decimals() value.

DecimalsByKey 

Allow the number of decimals to be controlled by adding/removing digits with key strokes.

See also
InsertDecimals, ReplaceDecimals
DecimalsByValue 

Allow the number of decimals to be controlled by the value set by setValue().

InsertDecimals 

This flag controls whether inserted intermediate decimals increase the number of decimals (on) or not (off). It is incompatible with the ReplaceDecimals flag.

See also
DecimalsByKey.
ReplaceDecimals 

This flag controls whether inserted intermediate decimals replace the existing decimals (on) or not (off). This is similar to Insert but just for decimal digits. It is incompatible with the InsertDecimals flag.

See also
DecimalsByKey, InsertDecimals
DecimalsAsMax 

Use the "decimals" property as a maximum limit for the number of decimals.

DecimalsAsMin 

Use the "decimals" property as a minimum limit for the number of decimals.

DecimalPointAlwaysVisible 

Even if the number of decimals is 0, it enforces the decimal to be visible (e.g. "0." )

See also
decimals

◆ SetMode

SetMode enums for the spinbox behavior. SetAlways: No check is made and the given parameters is directly set on the internal QDoubleSpinBox. SetIfDifferent: Default mode, the given parameter is checked against the current internal value and only set if they are different. For double, the comparison is based on the input parameters rounded with the current number of decimals (see round()).

See also
setMode(), setSetMode(), round()

Constructor & Destructor Documentation

◆ DoubleSpinBox()

DoubleSpinBox::DoubleSpinBox ( QWidget * parent = 0)
explicit

Constructor, creates a DoubleSpinBox. The look and feel are the same as of a QDoubleSpinBox

Member Function Documentation

◆ cleanText()

QString DoubleSpinBox::cleanText ( ) const

Get the spinbox current text. This excludes any prefix or suffix.

See also
value()

◆ decimals()

int DoubleSpinBox::decimals ( ) const

Set/Get number of displayed decimals. For a spinbox dealing only with integers, set this to 0.

See also
DoubleSpinBox::DecimalsOption

◆ decimalsOption()

DoubleSpinBox::DecimalsOptions DoubleSpinBox::decimalsOption ( )

Set/Get the option used to input the decimals.

See also
DoubleSpinBox::DecimalsOption

◆ displayedValue()

double DoubleSpinBox::displayedValue ( ) const

Get the spinbox current displayed value

See also
value(), cleanText(), setValue(), displayedValue()

◆ editingFinished

void DoubleSpinBox::editingFinished ( )
signal

Simple broadcast of the QAbstractSpinbox::editingFinished

See also
QAbstractSpinbox::editingFinished

◆ lineEdit()

QLineEdit * DoubleSpinBox::lineEdit ( ) const

Get a pointer on the line edit of the spinbox.

See also
QLineEdit, spinBox()

◆ minimumSizeHint()

QSize DoubleSpinBox::minimumSizeHint ( ) const
virtual

Reimplemented to respect the sizeHintPolicy property value.

See also
sizeHintPolicy

◆ prefix()

QString DoubleSpinBox::prefix ( ) const

Add/Get a prefix to the displayed value. For example, one might want to add the $ sign.

See also
suffix(), text()

◆ round()

double DoubleSpinBox::round ( double value) const

Returns the rounded value according to the number of decimals of the spinbox.

See also
decimals()

◆ setDecimals

void DoubleSpinBox::setDecimals ( int decimal)
slot

Set the decimals property value.

See also
decimals

◆ setDisplayedValue()

void DoubleSpinBox::setDisplayedValue ( double displayValue)

Set the displayed value if there is no proxy installed. If there is a proxy installed, then it allows to modify the proxy value. If there is no value proxy installed, then it's just a setter to the value property.

See also
displayedValue(), setValue(), value(), setValueProxy()

◆ setInvertedControls()

void DoubleSpinBox::setInvertedControls ( bool invertedControls)

This property holds whether or not the spin box inverts its wheel and key events. If this property is false, scrolling the mouse wheel "up" and using keys like page up will increase the spinbox's value towards its maximum. Otherwise pressing page up will move value towards the slider's minimum.

◆ setMode()

DoubleSpinBox::SetMode DoubleSpinBox::setMode ( ) const

Set the spinbox mode when using a set*() method. /.

See also
round(), setValue(), setValueIfDifferent(), setValueAlways()

◆ setPrefix()

void DoubleSpinBox::setPrefix ( const QString & prefix)

Setting the prefix doesn't recompute the sizehint, do it manually here: See: http://bugreports.qt.nokia.com/browse/QTBUG-9530

◆ setSizeHintPolicy()

void DoubleSpinBox::setSizeHintPolicy ( DoubleSpinBox::SizeHintPolicy newSizeHintPolicy)

Set the sizeHintPolicy property value.

See also
sizeHintPolicy

◆ setSuffix()

void DoubleSpinBox::setSuffix ( const QString & suffix)

Setting the suffix doesn't recompute the sizehint, do it manually here: See: http://bugreports.qt.nokia.com/browse/QTBUG-9530

◆ setValue

void DoubleSpinBox::setValue ( double value)
slot

Set the value of the spinbox following the current mode.

See also
setMode(), value(), setValueIfDifferent(), setValueAlways()

◆ setValueAlways

void DoubleSpinBox::setValueAlways ( double value)
slot

Set the value of the spinbox following the SetAlways mode.

See also
value(), setValue(), setMode(), setValueIfDifferent()

◆ setValueIfDifferent

void DoubleSpinBox::setValueIfDifferent ( double value)
slot

Set the value of the spinbox following the SetIfDifferent mode.

See also
value(), setValue(), setMode(), setValueAlways()

◆ setValueProxy()

void DoubleSpinBox::setValueProxy ( ValueProxy * proxy)

Install or remove a value proxy filter. The value proxy decouples the displayed value from the value retrieved by the value property. For example, the value proxy can allow one to display celsius in the spinbox while the value retrieved from the value property and signals are in fahrenheit. To remove the proxy, simply install a new empty proxy. The proxy installation/removal is silent.

See also
installValueProxy(), valueProxy()

◆ singleStep()

double DoubleSpinBox::singleStep ( ) const

Set/Get the single step. This represents by how much the value will decrease or increase when clicking the spinbox arrow or using stepUp or stepDown(). Default is 1.0.

See also
setUp(), stepDown(), setDecimals().

◆ sizeHint()

QSize DoubleSpinBox::sizeHint ( ) const
virtual

Reimplemented to respect the sizeHintPolicy property value.

See also
sizeHintPolicy

◆ sizeHintPolicy()

DoubleSpinBox::SizeHintPolicy DoubleSpinBox::sizeHintPolicy ( ) const

Return the sizeHintPolicy property value.

See also
sizeHintPolicy

◆ spinBox()

QDoubleSpinBox * DoubleSpinBox::spinBox ( ) const

Get a pointer on the spinbox used internally. It can be useful to change display properties for example. To use with caution.

See also
QDoubleSpinBox, lineEdit()

◆ stepUp

void DoubleSpinBox::stepUp ( )
slot

Increase/Decrease the current value by a single step.

See also
value(), singleStep()

◆ suffix()

QString DoubleSpinBox::suffix ( ) const

Add/Get a suffix to the displayed value. For example, one might want to add the F (fahrenheit) sign.

See also
prefix(), text()

◆ text()

QString DoubleSpinBox::text ( ) const

Get the spinbox current text. This includes any prefix or suffix.

See also
prefix(), suffix()

◆ value()

double DoubleSpinBox::value ( ) const

Get the spinbox current value

See also
setValue(), cleanText()

◆ valueChanged

void DoubleSpinBox::valueChanged ( double )
signal

Emitted every time the spinbox value is modified

See also
QDoubleSpinBox::valueChanged()

Property Documentation

◆ decimals

int DoubleSpinBox::decimals
readwrite

This property holds the precision of the spin box, in decimals. Sets how many decimals the spinbox will use for displaying and interpreting doubles. If the flag DecimalsByShortcuts is set, decimals can be increased/decreased by Ctrl+/Ctrl-, Ctrl0 restores the original decimals value. If the flag DecimalsAsMax and/or DecimalsAsMin are set, decimals behave also as the max and/or min number of decimals settable by DecimalsByShortcuts, DecimalsByKey and DecimalsByValue. 2 by default.

See also
decimalsOption, decimals(), setDecimals(), decimalsChanged

◆ decimalsOption

DoubleSpinBox::DecimalsOptions DoubleSpinBox::decimalsOption
readwrite

This property provides more controls over the decimals. The default (DecimalsByShortcuts|InsertDecimals) behaves as a QDoubleSpinbox with an explicit control of decimals via shortcuts.

See also
DecimalsOptions, decimals

◆ invertedControls

bool DoubleSpinBox::invertedControls
readwrite

This property controls whether decreasing the value by the mouse button or mouse wheel increases the value of the widget, and inverts the control similarly in the other way round or not. The property is switched off by default.

See also
invertedControls(), setInvertedControls()

◆ setMode

SetMode DoubleSpinBox::setMode
readwrite

This property controls how setValue behaves.

See also
SetMode, setMode(), setSetMode(), value

◆ sizeHintPolicy

SizeHintPolicy DoubleSpinBox::sizeHintPolicy
readwrite

This property controls the size hint of the spinbox. SizeHintByMinMax by default SizeHintPolicy, sizeHintPolicy(), setSizeHintPolicy()

◆ value

double DoubleSpinBox::value
readwrite
See also
setMode, decimals

The documentation for this class was generated from the following files: