diff --git a/GUI/Views/CommonWidgets/DoubleSpinBox.cpp b/GUI/Views/CommonWidgets/DoubleSpinBox.cpp index f08d4180743283fab736b21ef39ce1dde038e586..c3ed8f23fb90e720e4f20cb9085e38c5f1c30833 100644 --- a/GUI/Views/CommonWidgets/DoubleSpinBox.cpp +++ b/GUI/Views/CommonWidgets/DoubleSpinBox.cpp @@ -14,10 +14,12 @@ #include "GUI/Views/CommonWidgets/DoubleSpinBox.h" #include "GUI/Views/CommonWidgets/GUIHelpers.h" +#include <QWheelEvent> DoubleSpinBox::DoubleSpinBox(QWidget* parent, const DoubleDescriptor& d) : QDoubleSpinBox(parent), m_valueDescriptor(d) { + setFocusPolicy(Qt::StrongFocus); GUI::View::Helpers::configSpinbox(this, d.decimals, d.limits); setToolTip(d.tooltip); setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); @@ -75,6 +77,14 @@ void DoubleSpinBox::setBaseValue(double baseValue) setValue(toDisplayValue(baseValue)); } +void DoubleSpinBox::wheelEvent(QWheelEvent* event) +{ + if (!hasFocus()) + event->ignore(); + else + QDoubleSpinBox::wheelEvent(event); +} + void DoubleSpinBox::onDisplayValueChanged(double newDisplayValue) { emit baseValueChanged(toBaseValue(newDisplayValue)); diff --git a/GUI/Views/CommonWidgets/DoubleSpinBox.h b/GUI/Views/CommonWidgets/DoubleSpinBox.h index 103ede224bd195f8e0f6a44dc982e73927f49605..922ec6124c407e3fa4ca4b2ac81ba415bde9eb5a 100644 --- a/GUI/Views/CommonWidgets/DoubleSpinBox.h +++ b/GUI/Views/CommonWidgets/DoubleSpinBox.h @@ -51,6 +51,9 @@ signals: //! newBaseValue is in the unit of the valueDescriptor. void baseValueChanged(double newBaseValue); +protected: + virtual void wheelEvent(QWheelEvent* event) override; + private: void onDisplayValueChanged(double newValue);