OpenHantek
Loading...
Searching...
No Matches
SiSpinBox Class Reference

A spin box with SI prefix support. This spin box supports the SI prefixes (k/M/G/T) after its value and allows floating point values. The step size is increasing in an exponential way, to keep the percentual difference between the steps at equal levels. More...

#include <sispinbox.h>

Inheritance diagram for SiSpinBox:

Public Member Functions

 SiSpinBox (QWidget *parent=0)
 Initializes the SiSpinBox internals.
 
 SiSpinBox (Unit unit, QWidget *parent=0)
 Initializes the SiSpinBox, allowing the user to choose the unit.
 
 ~SiSpinBox ()
 Cleans up the main window.
 
QValidator::State validate (QString &input, int &pos) const
 Validates the text after user input.
 
double valueFromText (const QString &text) const
 Parse value from input text.
 
QString textFromValue (double val) const
 Get string representation of value.
 
void fixup (QString &input) const
 Fixes the text after the user finished changing it.
 
void stepBy (int steps)
 Increase/decrease the values in fixed steps.
 
bool setUnit (Unit unit)
 Set the unit for this spin box.
 
void setUnitPostfix (const QString &postfix)
 Set the unit postfix for this spin box.
 
void setSteps (const QList< double > &steps)
 Set the steps the spin box will take.
 
void setMode (const int mode)
 Set the mode.
 

Detailed Description

A spin box with SI prefix support. This spin box supports the SI prefixes (k/M/G/T) after its value and allows floating point values. The step size is increasing in an exponential way, to keep the percentual difference between the steps at equal levels.

Constructor & Destructor Documentation

◆ SiSpinBox() [1/2]

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

Initializes the SiSpinBox internals.

Parameters
parentThe parent widget.

◆ SiSpinBox() [2/2]

SiSpinBox::SiSpinBox ( Unit unit,
QWidget * parent = 0 )

Initializes the SiSpinBox, allowing the user to choose the unit.

Parameters
unitThe unit shown for the value in the spin box.
parentThe parent widget.

Member Function Documentation

◆ fixup()

void SiSpinBox::fixup ( QString & input) const

Fixes the text after the user finished changing it.

Parameters
inputThe content of the text box.

◆ setMode()

void SiSpinBox::setMode ( const int mode)

Set the mode.

Parameters
modeThe mode, the value 0 will have fixed interval, otherwise the value will have interval within steps itself.

◆ setSteps()

void SiSpinBox::setSteps ( const QList< double > & steps)

Set the steps the spin box will take.

Parameters
stepsThe steps, will be extended with the ratio from the start after the last element.

◆ setUnit()

bool SiSpinBox::setUnit ( Unit unit)

Set the unit for this spin box.

Parameters
unitThe unit shown for the value in the spin box.
Returns
true on success, false on invalid unit.

◆ setUnitPostfix()

void SiSpinBox::setUnitPostfix ( const QString & postfix)

Set the unit postfix for this spin box.

Parameters
postfixthe string shown after the unit in the spin box.

◆ stepBy()

void SiSpinBox::stepBy ( int steps)

Increase/decrease the values in fixed steps.

Parameters
stepsThe number of steps, positive means increase.

◆ textFromValue()

QString SiSpinBox::textFromValue ( double val) const

Get string representation of value.

Parameters
valValue in base unit.
Returns
String representation containing value and (prefix+)unit.

◆ validate()

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

Validates the text after user input.

Parameters
inputThe content of the text box.
posThe position of the cursor in the text box.
Returns
Validity of the current text.

◆ valueFromText()

double SiSpinBox::valueFromText ( const QString & text) const

Parse value from input text.

Parameters
textThe content of the text box.
Returns
Value in base unit.

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