diff --git a/src/Gui/QuantitySpinBox.cpp b/src/Gui/QuantitySpinBox.cpp index 38a265e38a..abfbb04e34 100644 --- a/src/Gui/QuantitySpinBox.cpp +++ b/src/Gui/QuantitySpinBox.cpp @@ -282,14 +282,6 @@ QuantitySpinBox::QuantitySpinBox(QWidget *parent) this, [&]{ this->handlePendingEmit(true); }); - - // When a style sheet is set the text margins for top/bottom must be set to avoid to squash the widget -#ifndef Q_OS_MAC - lineEdit()->setTextMargins(0, 2, 0, 2); -#else - // https://forum.freecad.org/viewtopic.php?f=8&t=50615 - lineEdit()->setTextMargins(0, 2, 0, 0); -#endif } QuantitySpinBox::~QuantitySpinBox() = default; diff --git a/src/Gui/SpinBox.cpp b/src/Gui/SpinBox.cpp index 052e27cbbc..fbdcfc1abe 100644 --- a/src/Gui/SpinBox.cpp +++ b/src/Gui/SpinBox.cpp @@ -54,6 +54,14 @@ ExpressionSpinBox::ExpressionSpinBox(QAbstractSpinBox* sb) QObject::connect(iconLabel, &ExpressionLabel::clicked, [this]() { this->openFormulaDialog(); }); + + // Set Margins + // vertical to avoid this: https://forum.freecad.org/viewtopic.php?f=8&t=50615 + // horizontal to avoid going under the icon + lineedit->setAlignment(Qt::AlignVCenter); + int iconWidth = iconLabel->sizeHint().width(); + int margin = lineedit->style()->pixelMetric(QStyle::PM_LineEditIconMargin, nullptr, lineedit); + lineedit->setTextMargins(margin, margin, margin + iconWidth, margin); } ExpressionSpinBox::~ExpressionSpinBox() = default;