Files
newspark110/customcontrols/dmdoublespinbox.cpp
Chenwenxuan edac2715f0 init
2024-03-06 14:54:30 +08:00

34 lines
852 B
C++

#include "dmdoublespinbox.h"
#include "eventfilterwheel.h"
#include <QDebug>
#include <QEvent>
DMDoubleSpinBox::DMDoubleSpinBox(QWidget *parent) :
QDoubleSpinBox(parent)
{
installEventFilter(new EventFilterWheel());
// 只有在鼠标点击或按下tab键时获取焦点
setFocusPolicy(Qt::StrongFocus);
setKeyboardTracking(false);
installEventFilter(this);
}
#ifdef QT_DEBUG
bool DMDoubleSpinBox::eventFilter(QObject *watched, QEvent *event)
{
// Q_UNUSED(watched)
// QDoubleSpinBox *castSBox = static_cast<QDoubleSpinBox*>(watched);
if(event->type()==QEvent::Timer)
{
QTimerEvent *tEvent = static_cast<QTimerEvent*>(event);
if(tEvent)
qDebug() << "<--QEvent::Timer-->" << tEvent->timerId();
return true;
}
return QObject::eventFilter(watched,event);
}
#endif