From: vsv Date: Fri, 6 Jul 2018 13:05:11 +0000 (+0300) Subject: Issue #2567: Fix integer value representation X-Git-Tag: EDF_2018-1~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=30f7450feac77d53c94af9ccdf4641365b96fb27;p=modules%2Fshaper.git Issue #2567: Fix integer value representation --- 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;