From 356aa0019384346fa23f4fd20c373605f7b37b39 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 5 Oct 2017 22:46:02 +0200 Subject: [PATCH] add new property rawValue to QuantitySpinBox to make it accessible from Python --- src/Gui/QuantitySpinBox.cpp | 6 ++++++ src/Gui/QuantitySpinBox.h | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Gui/QuantitySpinBox.cpp b/src/Gui/QuantitySpinBox.cpp index b3e72bdd4f..32a0bbd4ca 100644 --- a/src/Gui/QuantitySpinBox.cpp +++ b/src/Gui/QuantitySpinBox.cpp @@ -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); diff --git a/src/Gui/QuantitySpinBox.h b/src/Gui/QuantitySpinBox.h index c719e88e36..a7fdbf0b8e 100644 --- a/src/Gui/QuantitySpinBox.h +++ b/src/Gui/QuantitySpinBox.h @@ -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: