Gui: QuantitySpinBox - keep format on setValue

==============================================

Problem:
When the value set is a double, a new Quantity is created, which does not follow
the previously configured format (setDecimals).

Solution:
To copy the old format to the newly created quantity.
This commit is contained in:
Abdullah Tahiri
2023-11-15 15:22:42 +01:00
committed by wwmayer
parent 5a39a85b73
commit 6a9fa8da68

View File

@@ -495,7 +495,12 @@ void QuantitySpinBox::setValue(const Base::Quantity& value)
void QuantitySpinBox::setValue(double value)
{
Q_D(QuantitySpinBox);
setValue(Base::Quantity(value, d->unit));
Base::QuantityFormat currentformat = d->quantity.getFormat();
auto quantity = Base::Quantity(value, d->unit);
quantity.setFormat(currentformat);
setValue(quantity);
}
bool QuantitySpinBox::hasValidInput() const