Added read-only 'expression' property to QunatitySpinBox and renamed 'boundTo' to 'binding'.

This commit is contained in:
Markus Lampert
2017-10-06 19:02:44 -07:00
committed by wmayer
parent 7a352fea52
commit b28e48c10b
2 changed files with 17 additions and 3 deletions

View File

@@ -328,8 +328,18 @@ void QuantitySpinBox::setBoundToByName(const QString &qstr)
}
}
void Gui::QuantitySpinBox::onChange() {
QString Gui::QuantitySpinBox::expressionText() const
{
Q_D(const QuantitySpinBox);
if (isBound()) {
return QString::fromStdString(getExpressionString());
}
return QString();
}
void Gui::QuantitySpinBox::onChange()
{
Q_ASSERT(isBound());
if (getExpression()) {

View File

@@ -45,7 +45,8 @@ class GuiExport QuantitySpinBox : public QAbstractSpinBox, public ExpressionBind
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)
Q_PROPERTY(QString boundTo READ boundToName WRITE setBoundToByName)
Q_PROPERTY(QString binding READ boundToName WRITE setBoundToByName)
Q_PROPERTY(QString expression READ expressionText)
public:
using ExpressionBinding::apply;
@@ -95,6 +96,9 @@ public:
/// Sets the path of the bound property
void setBoundToByName(const QString &path);
/// Gets the expression as a string
QString expressionText() const;
/// Set the number portion selected
void selectNumber();