mirror of
https://github.com/tnodir/fort
synced 2024-11-15 09:59:38 +00:00
UI: DoubleSpinBox: Don't auto-focus on wheel event
This commit is contained in:
parent
dce4e6447c
commit
6dfd4373c2
@ -40,6 +40,7 @@ SOURCES += \
|
||||
form/controls/clickablemenu.cpp \
|
||||
form/controls/combobox.cpp \
|
||||
form/controls/controlutil.cpp \
|
||||
form/controls/doublespinbox.cpp \
|
||||
form/controls/labelcolor.cpp \
|
||||
form/controls/labeldoublespin.cpp \
|
||||
form/controls/labelspin.cpp \
|
||||
@ -231,6 +232,7 @@ HEADERS += \
|
||||
form/controls/clickablemenu.h \
|
||||
form/controls/combobox.h \
|
||||
form/controls/controlutil.h \
|
||||
form/controls/doublespinbox.h \
|
||||
form/controls/labelcolor.h \
|
||||
form/controls/labeldoublespin.h \
|
||||
form/controls/labelspin.h \
|
||||
|
18
src/ui/form/controls/doublespinbox.cpp
Normal file
18
src/ui/form/controls/doublespinbox.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
#include "doublespinbox.h"
|
||||
|
||||
#include <QWheelEvent>
|
||||
|
||||
DoubleSpinBox::DoubleSpinBox(QWidget *parent) : QDoubleSpinBox(parent)
|
||||
{
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
}
|
||||
|
||||
void DoubleSpinBox::wheelEvent(QWheelEvent *e)
|
||||
{
|
||||
if (!hasFocus()) {
|
||||
e->ignore();
|
||||
return;
|
||||
}
|
||||
|
||||
QDoubleSpinBox::wheelEvent(e);
|
||||
}
|
17
src/ui/form/controls/doublespinbox.h
Normal file
17
src/ui/form/controls/doublespinbox.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef DOUBLESPINBOX_H
|
||||
#define DOUBLESPINBOX_H
|
||||
|
||||
#include <QDoubleSpinBox>
|
||||
|
||||
class DoubleSpinBox : public QDoubleSpinBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DoubleSpinBox(QWidget *parent = nullptr);
|
||||
|
||||
protected:
|
||||
void wheelEvent(QWheelEvent *e) override;
|
||||
};
|
||||
|
||||
#endif // DOUBLESPINBOX_H
|
@ -1,10 +1,10 @@
|
||||
#include "labeldoublespin.h"
|
||||
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
|
||||
#include "controlutil.h"
|
||||
#include "doublespinbox.h"
|
||||
|
||||
LabelDoubleSpin::LabelDoubleSpin(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
@ -29,7 +29,7 @@ void LabelDoubleSpin::setupUi()
|
||||
|
||||
void LabelDoubleSpin::setupSpin()
|
||||
{
|
||||
m_spinBox = new QDoubleSpinBox();
|
||||
m_spinBox = new DoubleSpinBox();
|
||||
m_spinBox->setMinimumWidth(110);
|
||||
m_spinBox->setRange(0, 9999);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user