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