123456789101112131415161718192021222324252627282930313233343536373839404142 |
- #include "SpinBox.h"
- #include <QLineEdit>
- #include <QEvent>
- #include <QDebug>
- 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);
- }
- }
|