17 #include <QWheelEvent>
20 : QDoubleSpinBox(parent)
21 , m_valueDescriptor(d)
23 setFocusPolicy(Qt::StrongFocus);
26 setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
33 QObject::connect(
this, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this,
46 setSuffix(
" " + suffix);
49 QSignalBlocker b(
this);
86 QDoubleSpinBox::wheelEvent(event);
104 QSignalBlocker b(
this);
Defines class DoubleSpinBox.
Defines class GUIHelpers functions.
QString unitAsString(const Unit &unit)
Returns the string for the given unit.
double convert(double d, Unit from, Unit to)
Convert the given value d from unit "from" to unit "to" Throws an exception if no conversion possible...
Unit
Defines units, mainly to be able to convert between units.
@ other
The unit has no enum value defined in here (e.g. when defined as an explicit string)
Describes properties of a double value which are necessary to allow GUI representation,...
variant< QString, Unit > unit
Unit of the value (internal unit only!)
RealLimits limits
Limits of the value.
function< double()> get
function to get the current value
QString tooltip
Tooltip text.
int decimals
numbers of decimals to be shown in an edit control
Unit baseUnit() const
Returns the unit of the contained DoubleDescriptor.
DoubleDescriptor m_valueDescriptor
double toBaseValue(double displayValue) const
void updateValue()
Update the shown value to the one contained in the value descriptor.
void wheelEvent(QWheelEvent *event) override
const DoubleDescriptor & valueDescriptor() const
The descriptor on which this spinbox operates.
void setDisplayUnit(Unit displayUnit)
Set a display unit.
void setBaseValue(double baseValue)
Set the base value (unit is the one of the contained descriptor).
bool m_showUnitAsSuffix
it was decided to not show the unit as a suffix. However, this may be user selectable once,...
DoubleSpinBox(QWidget *parent, const DoubleDescriptor &d)
Create a DoubleSpinBox with the information found in a DoubleDescriptor.
QString displayUnitAsString() const
The display unit as human readable string.
void baseValueChanged(double newBaseValue)
Emitted whenever the value changes.
void onDisplayValueChanged(double newDisplayValue)
double toDisplayValue(double baseValue) const
void configSpinbox(QDoubleSpinBox *spinBox, int decimals, const RealLimits &limits)