add new property rawValue to QuantitySpinBox to make it accessible from Python

This commit is contained in:
wmayer
2017-10-05 22:46:02 +02:00
parent 1d17c043eb
commit 356aa00193
2 changed files with 10 additions and 2 deletions

View File

@@ -413,6 +413,12 @@ Base::Quantity QuantitySpinBox::value() const
return d->quantity;
}
double QuantitySpinBox::rawValue() const
{
Q_D(const QuantitySpinBox);
return d->quantity.getValue();
}
void QuantitySpinBox::setValue(const Base::Quantity& value)
{
Q_D(QuantitySpinBox);

View File

@@ -43,6 +43,7 @@ class GuiExport QuantitySpinBox : public QAbstractSpinBox, public ExpressionBind
Q_PROPERTY(double minimum READ minimum WRITE setMinimum)
Q_PROPERTY(double maximum READ maximum WRITE setMaximum)
Q_PROPERTY(double singleStep READ singleStep WRITE setSingleStep)
Q_PROPERTY(double rawValue READ rawValue WRITE setValue NOTIFY valueChanged)
Q_PROPERTY(Base::Quantity value READ value WRITE setValue NOTIFY valueChanged USER true)
public:
@@ -53,6 +54,8 @@ public:
/// Get the current quantity
Base::Quantity value() const;
/// Get the current quantity without unit
double rawValue() const;
/// Gives the current state of the user input, gives true if it is a valid input with correct quantity
/// or returns false if the input is a unparsable string or has a wrong unit.
@@ -123,11 +126,10 @@ protected:
virtual void showEvent(QShowEvent * event);
virtual void focusInEvent(QFocusEvent * event);
virtual void focusOutEvent(QFocusEvent * event);
virtual void keyPressEvent(QKeyEvent *event);
virtual void keyPressEvent(QKeyEvent *event);
virtual void resizeEvent(QResizeEvent *event);
private:
void updateText(const Base::Quantity&);
Q_SIGNALS: