From bd98e41ca1db158659afc9f53db04af37cac6d96 Mon Sep 17 00:00:00 2001 From: jpark37 Date: Sun, 2 May 2021 09:38:41 -0700 Subject: [PATCH] UI: Fix rounding truncation Set decimal places before value on QDoubleSpinBox to preserve precision. --- UI/properties-view.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/UI/properties-view.cpp b/UI/properties-view.cpp index a7d88b84a..a92ae7936 100644 --- a/UI/properties-view.cpp +++ b/UI/properties-view.cpp @@ -393,13 +393,6 @@ void OBSPropertiesView::AddFloat(obs_property_t *prop, QFormLayout *layout, double stepVal = obs_property_float_step(prop); const char *suffix = obs_property_float_suffix(prop); - spin->setMinimum(minVal); - spin->setMaximum(maxVal); - spin->setSingleStep(stepVal); - spin->setValue(val); - spin->setToolTip(QT_UTF8(obs_property_long_description(prop))); - spin->setSuffix(QT_UTF8(suffix)); - if (stepVal < 1.0) { int decimals = (int)(log10(1.0 / stepVal) + 0.99); constexpr int sane_limit = 8; @@ -408,6 +401,13 @@ void OBSPropertiesView::AddFloat(obs_property_t *prop, QFormLayout *layout, spin->setDecimals(decimals); } + spin->setMinimum(minVal); + spin->setMaximum(maxVal); + spin->setSingleStep(stepVal); + spin->setValue(val); + spin->setToolTip(QT_UTF8(obs_property_long_description(prop))); + spin->setSuffix(QT_UTF8(suffix)); + WidgetInfo *info = new WidgetInfo(this, prop, spin); children.emplace_back(info);