A spin box that can display values in different units. More...
#include <klfunitinput.h>
Public Slots | |
void | setUnit (double unitfactor) |
void | setUnitWithSuffix (double unitfactor, const QString &suffix) |
void | setShowUnitSuffix (bool show) |
void | setValueInRefUnit (double value) |
Signals | |
void | valueInRefUnitChanged (double value) |
Public Member Functions | |
KLFUnitSpinBox (QWidget *parent=NULL) | |
virtual | ~KLFUnitSpinBox () |
double | unitFactor () const |
bool | showUnitSuffix () const |
double | valueInRefUnit () const |
Properties | |
double | valurInRefUnit |
double | unitFactor |
bool | showUnitSuffix |
A spin box that can display values in different units.
This widget presents a spin box which displays a value, which by default is shown in the 'reference unit', for which the 'unit factor' is 1
.
Other units may be set (eg. by connecting our setUnit(double) slot to the unitChanged(double) signal of a KLFUnitChooser) which have other unit factors telling how to convert the other value into the 'ref unit' value.
Example:
When units are changed, the minimum and maximum are adjusted to the value in the new units.
The precision ( QDoubleSpinBox::setDecimals()) is also adjusted to the right order of magnitude (power of 10). For example, if the value of 18.3mm is displayed with 1 decimal place, and a unit is set with factor of 1000
(m) then the presision is adjusted to 4 decimal places. And if a unit is set with factor of 304.8
(foot) then the precision is adjusted to 3 decimal places. Details: the number of decimal places to adjust is determined by rounding the value log_10(unit-factor)
to the nearest integer.
Definition at line 149 of file klfunitinput.h.
KLFUnitSpinBox::KLFUnitSpinBox | ( | QWidget * | parent = NULL | ) |
Definition at line 150 of file klfunitinput.cpp.
|
virtual |
Definition at line 157 of file klfunitinput.cpp.
|
slot |
Whether to display the unit suffix or not. This only works if you use setUnitWithSuffix() to set new units.
Definition at line 201 of file klfunitinput.cpp.
References klfDbg, and valueInRefUnitChanged().
|
slot |
Definition at line 161 of file klfunitinput.cpp.
References klfDbg.
Referenced by setUnitWithSuffix().
|
slot |
Display the current value converted to the new unit using unitfactor
, and if showUnitSuffix() is TRUE, then displays the given suffix.
Definition at line 189 of file klfunitinput.cpp.
References setUnit().
|
slot |
Definition at line 196 of file klfunitinput.cpp.
|
inline |
Definition at line 161 of file klfunitinput.h.
|
inline |
Definition at line 159 of file klfunitinput.h.
|
inline |
Definition at line 163 of file klfunitinput.h.
|
signal |
Referenced by setShowUnitSuffix().
|
readwrite |
Definition at line 154 of file klfunitinput.h.
|
readwrite |
Definition at line 153 of file klfunitinput.h.
|
readwrite |
Definition at line 152 of file klfunitinput.h.