Salome HOME
Issue #2567: Fix integer value representation
authorvsv <vsv@opencascade.com>
Fri, 6 Jul 2018 13:05:11 +0000 (16:05 +0300)
committervsv <vsv@opencascade.com>
Fri, 6 Jul 2018 13:05:11 +0000 (16:05 +0300)
src/ModuleBase/ModuleBase_ParamSpinBox.cpp
src/ModuleBase/ModuleBase_ParamSpinBox.h

index f3dfd36b56b0b4223778987f2833edd2223cb130..1944bc47ec2aa0b1e8953c9d9d07881e8588bb2c 100644 (file)
@@ -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);
index a2a4086980645fd47b89535bcce26c736edd48f6..8437b746cc8967641c7de81f8cbf7b7316f72795 100644 (file)
@@ -152,7 +152,6 @@ private:
 
   QStringListModel* myCompleterModel;
   QCompleter* myCompleter;
-  int myPrecision;
 
   double myMinimum;
   double myMaximum;