#include "DoubleSpinBox.h" #include #include #include DoubleSpinBox::DoubleSpinBox(QWidget *parent) : QDoubleSpinBox(parent) { setButtonSymbols(QAbstractSpinBox::NoButtons); installEventFilter(this); setMaximum(1000000000); setMinimum(-100000000); m_lineEdit = this->lineEdit(); connect(m_lineEdit, &QLineEdit::textChanged, this, [=]() { m_valueChangeFalg = true; }); // 连接 editingFinished 信号来处理编辑完成事件 connect(this, &QDoubleSpinBox::editingFinished, this, [=]() { if (m_valueChangeFalg) { emit editDone(); } }); } DoubleSpinBox::~DoubleSpinBox() { } bool DoubleSpinBox::eventFilter(QObject *watched, QEvent *event) { if (event->type() == QEvent::Wheel) { return true; } else { return QDoubleSpinBox::eventFilter(watched, event); } }