Skip to content

Commit

Permalink
Gui: set/get number of decimals of a quantity spin box
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Dec 20, 2019
1 parent 0754965 commit b6ae122
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Gui/QuantitySpinBox.cpp
Expand Up @@ -682,6 +682,21 @@ void QuantitySpinBox::setRange(double minimum, double maximum)
d->maximum = maximum;
}

int QuantitySpinBox::decimals() const
{
Q_D(const QuantitySpinBox);
return d->quantity.getFormat().precision;
}

void QuantitySpinBox::setDecimals(int v)
{
Q_D(QuantitySpinBox);
Base::QuantityFormat f = d->quantity.getFormat();
f.precision = v;
d->quantity.setFormat(f);
updateText(d->quantity);
}

QAbstractSpinBox::StepEnabled QuantitySpinBox::stepEnabled() const
{
Q_D(const QuantitySpinBox);
Expand Down
5 changes: 5 additions & 0 deletions src/Gui/QuantitySpinBox.h
Expand Up @@ -91,6 +91,11 @@ class GuiExport QuantitySpinBox : public QAbstractSpinBox, public ExpressionBind
/// Sets the value of the maximum property
void setMaximum(double max);

/// Gets the number of decimals
int decimals() const;
/// Sets the number of decimals
void setDecimals(int v);

/// Gets the path of the bound property
QString boundToName() const;
/// Sets the path of the bound property
Expand Down

0 comments on commit b6ae122

Please sign in to comment.