From 6a9fa8da68619d2e7d60f0ec02ad20e227b7e9fd Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Wed, 15 Nov 2023 15:22:42 +0100 Subject: [PATCH] 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. --- src/Gui/QuantitySpinBox.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Gui/QuantitySpinBox.cpp b/src/Gui/QuantitySpinBox.cpp index 91bc452d6a..3d9dec3a29 100644 --- a/src/Gui/QuantitySpinBox.cpp +++ b/src/Gui/QuantitySpinBox.cpp @@ -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