Mantid
Loading...
Searching...
No Matches
Signals | Public Member Functions | Protected Member Functions | Private Slots | Private Attributes | List of all members
DoubleSpinBox Class Reference

A QDoubleSpinBox allowing to customize numbers display with respect to. More...

#include <DoubleSpinBox.h>

Inheritance diagram for DoubleSpinBox:

Signals

void activated (DoubleSpinBox *)
 Signal emitted when the spin box gains focus. More...
 
void valueChanged (double d)
 

Public Member Functions

void addSpecialTextMapping (const QString &text, double value)
 Adds a mapping from string whihc may be entered into the edit box and a double value. More...
 
int decimals ()
 
 DoubleSpinBox (const char format='g', QWidget *parent=nullptr)
 Constructor. More...
 
double getMaximum ()
 
double getMinimum ()
 
void setDecimals (int prec)
 
void setFormat (const char format, int prec=1)
 
void setMaximum (double max)
 
void setMinimum (double min)
 
void setRange (double min, double max)
 
void setSingleStep (double val)
 
bool setValue (double val)
 
QString textFromValue (double value) const
 
QValidator::State validate (QString &input, int &pos) const override
 
double value ()
 

Protected Member Functions

void focusInEvent (QFocusEvent *) override
 
void stepBy (int steps) override
 
StepEnabled stepEnabled () const override
 

Private Slots

void interpretText (bool notify=true)
 Interpret the text and update the stored value. More...
 

Private Attributes

char d_format
 
double d_max_val
 
double d_min_val
 
int d_prec
 
double d_step
 
double d_value
 
std::map< QString, double > m_specialTextMappings
 

Detailed Description

A QDoubleSpinBox allowing to customize numbers display with respect to.

It allows the user to specify a custom display format.

Definition at line 31 of file DoubleSpinBox.h.

Constructor & Destructor Documentation

◆ DoubleSpinBox()

DoubleSpinBox::DoubleSpinBox ( const char  format = 'g',
QWidget *  parent = nullptr 
)

Constructor.

Parameters
formatformat used to display numbers: has the same meaning as in QLocale::toString ( double i, char f = 'g', int prec = 6 )
parentparent widget (only affects placement of the dialog)

Definition at line 27 of file DoubleSpinBox.cpp.

References d_format, d_prec, d_value, and interpretText().

Member Function Documentation

◆ activated

void DoubleSpinBox::activated ( DoubleSpinBox )
signal

Signal emitted when the spin box gains focus.

Referenced by focusInEvent().

◆ addSpecialTextMapping()

void DoubleSpinBox::addSpecialTextMapping ( const QString &  text,
double  value 
)

Adds a mapping from string whihc may be entered into the edit box and a double value.

The mapping is case sensitive

Parameters
textQString with text to map
valueValue to map it to

Definition at line 118 of file DoubleSpinBox.cpp.

References m_specialTextMappings, and value().

◆ decimals()

int DoubleSpinBox::decimals ( )
inline

Definition at line 51 of file DoubleSpinBox.h.

◆ focusInEvent()

void DoubleSpinBox::focusInEvent ( QFocusEvent *  e)
overrideprotected

Definition at line 170 of file DoubleSpinBox.cpp.

References activated().

◆ getMaximum()

double DoubleSpinBox::getMaximum ( )

Definition at line 51 of file DoubleSpinBox.cpp.

References d_max_val.

◆ getMinimum()

double DoubleSpinBox::getMinimum ( )

Definition at line 60 of file DoubleSpinBox.cpp.

References d_min_val.

◆ interpretText

void DoubleSpinBox::interpretText ( bool  notify = true)
privateslot

Interpret the text and update the stored value.

Parameters
notifyIf true then emit signals to indicate if the value has changed (default=true) The default is important so that connected signals ensure the correct updates are pushed through but we need to be able to turn them off as there are cases where this causes a recursive call.

Definition at line 77 of file DoubleSpinBox.cpp.

References d_value, m_specialTextMappings, setValue(), textFromValue(), value(), and valueChanged().

Referenced by DoubleSpinBox(), and value().

◆ setDecimals()

void DoubleSpinBox::setDecimals ( int  prec)
inline

Definition at line 52 of file DoubleSpinBox.h.

◆ setFormat()

void DoubleSpinBox::setFormat ( const char  format,
int  prec = 1 
)
inline

Definition at line 60 of file DoubleSpinBox.h.

◆ setMaximum()

void DoubleSpinBox::setMaximum ( double  max)

Definition at line 44 of file DoubleSpinBox.cpp.

References d_max_val.

Referenced by setRange().

◆ setMinimum()

void DoubleSpinBox::setMinimum ( double  min)

Definition at line 53 of file DoubleSpinBox.cpp.

References d_min_val.

Referenced by setRange().

◆ setRange()

void DoubleSpinBox::setRange ( double  min,
double  max 
)

Definition at line 62 of file DoubleSpinBox.cpp.

References setMaximum(), and setMinimum().

◆ setSingleStep()

void DoubleSpinBox::setSingleStep ( double  val)

Definition at line 39 of file DoubleSpinBox.cpp.

References d_max_val, and d_step.

◆ setValue()

bool DoubleSpinBox::setValue ( double  val)

Definition at line 147 of file DoubleSpinBox.cpp.

References d_max_val, d_min_val, d_value, and textFromValue().

Referenced by interpretText(), RangeLimitBox::RangeLimitBox(), and stepBy().

◆ stepBy()

void DoubleSpinBox::stepBy ( int  steps)
overrideprotected

Definition at line 120 of file DoubleSpinBox.cpp.

References d_step, d_value, fabs, setValue(), and valueChanged().

◆ stepEnabled()

QAbstractSpinBox::StepEnabled DoubleSpinBox::stepEnabled ( ) const
overrideprotected

Definition at line 129 of file DoubleSpinBox.cpp.

References d_max_val, d_min_val, and d_value.

◆ textFromValue()

QString DoubleSpinBox::textFromValue ( double  value) const

Definition at line 158 of file DoubleSpinBox.cpp.

References d_format, d_min_val, d_prec, and value().

Referenced by interpretText(), and setValue().

◆ validate()

QValidator::State DoubleSpinBox::validate ( QString &  input,
int &  pos 
) const
override

Definition at line 168 of file DoubleSpinBox.cpp.

◆ value()

double DoubleSpinBox::value ( )

◆ valueChanged

void DoubleSpinBox::valueChanged ( double  d)
signal

Referenced by interpretText(), and stepBy().

Member Data Documentation

◆ d_format

char DoubleSpinBox::d_format
private

Definition at line 84 of file DoubleSpinBox.h.

Referenced by DoubleSpinBox(), and textFromValue().

◆ d_max_val

double DoubleSpinBox::d_max_val
private

Definition at line 86 of file DoubleSpinBox.h.

Referenced by getMaximum(), setMaximum(), setSingleStep(), setValue(), and stepEnabled().

◆ d_min_val

double DoubleSpinBox::d_min_val
private

Definition at line 85 of file DoubleSpinBox.h.

Referenced by getMinimum(), setMinimum(), setValue(), stepEnabled(), and textFromValue().

◆ d_prec

int DoubleSpinBox::d_prec
private

Definition at line 89 of file DoubleSpinBox.h.

Referenced by DoubleSpinBox(), and textFromValue().

◆ d_step

double DoubleSpinBox::d_step
private

Definition at line 88 of file DoubleSpinBox.h.

Referenced by setSingleStep(), and stepBy().

◆ d_value

double DoubleSpinBox::d_value
private

Definition at line 87 of file DoubleSpinBox.h.

Referenced by DoubleSpinBox(), interpretText(), setValue(), stepBy(), stepEnabled(), and value().

◆ m_specialTextMappings

std::map<QString, double> DoubleSpinBox::m_specialTextMappings
private

Definition at line 93 of file DoubleSpinBox.h.

Referenced by addSpecialTextMapping(), and interpretText().


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