From 30f7450feac77d53c94af9ccdf4641365b96fb27 Mon Sep 17 00:00:00 2001 From: vsv Date: Fri, 6 Jul 2018 16:05:11 +0300 Subject: [PATCH] Issue #2567: Fix integer value representation --- src/ModuleBase/ModuleBase_ParamSpinBox.cpp | 6 +++--- src/ModuleBase/ModuleBase_ParamSpinBox.h | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/ModuleBase/ModuleBase_ParamSpinBox.cpp b/src/ModuleBase/ModuleBase_ParamSpinBox.cpp index f3dfd36b5..1944bc47e 100644 --- a/src/ModuleBase/ModuleBase_ParamSpinBox.cpp +++ b/src/ModuleBase/ModuleBase_ParamSpinBox.cpp @@ -46,7 +46,6 @@ bool isVariableSymbol(const QChar& theChar) { ModuleBase_ParamSpinBox::ModuleBase_ParamSpinBox(QWidget* theParent, int thePrecision) : QAbstractSpinBox(theParent), - myPrecision(thePrecision), myIsEquation(false), myAcceptVariables(true), mySingleStep(1), @@ -75,7 +74,7 @@ ModuleBase_ParamSpinBox::ModuleBase_ParamSpinBox(QWidget* theParent, int thePrec myValidator = new QDoubleValidator(this); myValidator->setLocale(locale()); myValidator->setRange(myMinimum, myMaximum); - myValidator->setDecimals(myPrecision); + myValidator->setDecimals(thePrecision); } void ModuleBase_ParamSpinBox::setCompletionList(QStringList& theList) @@ -153,7 +152,8 @@ void ModuleBase_ParamSpinBox::setValue(double value) aVal = myMinimum; else if (aVal > myMaximum) aVal = myMaximum; - QString aText = QString::number(aVal, 'g', decimals()); + QString aText = (myValidator->decimals() == 0) ? QString::number((int)aVal) : + QString::number(aVal, 'g', decimals()); lineEdit()->blockSignals(true); lineEdit()->setText(aText); lineEdit()->blockSignals(false); diff --git a/src/ModuleBase/ModuleBase_ParamSpinBox.h b/src/ModuleBase/ModuleBase_ParamSpinBox.h index a2a408698..8437b746c 100644 --- a/src/ModuleBase/ModuleBase_ParamSpinBox.h +++ b/src/ModuleBase/ModuleBase_ParamSpinBox.h @@ -152,7 +152,6 @@ private: QStringListModel* myCompleterModel; QCompleter* myCompleter; - int myPrecision; double myMinimum; double myMaximum; -- 2.39.2