#ifndef CustomWidgets_H #define CustomWidgets_H #include #include #include #include #include #include //^======================================= class RComboBox : public QComboBox{ public : RComboBox(QWidget * parent = nullptr): QComboBox(parent){ setFocusPolicy(Qt::StrongFocus); } protected: void wheelEvent(QWheelEvent * event) override{ event->ignore(); } }; //^======================================= class RSpinBox : public QDoubleSpinBox{ Q_OBJECT public : RSpinBox(QWidget * parent = nullptr, int decimal = 0): QDoubleSpinBox(parent){ setFocusPolicy(Qt::StrongFocus); setDecimals(decimal); } signals: void returnPressed(); protected: void wheelEvent(QWheelEvent * event) override{ event->ignore(); } void keyPressEvent(QKeyEvent * event) override{ if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) { emit returnPressed(); } else { QDoubleSpinBox::keyPressEvent(event); } } }; #endif