9249403c96
Ignore wheelEvent using subclass slider,spinbox,combobox with eventhandlers: wheelEvent - ignore if widget is not focused, leaveEvent - clear focus when mouse leaves event. Use these new subclass widgets in properties to ignore wheelEvent when scrolling.
20 lines
361 B
C++
20 lines
361 B
C++
#include "spinBox-ignorewheel.hpp"
|
|
|
|
SpinBoxIgnoreScroll::SpinBoxIgnoreScroll(QWidget *parent) : QSpinBox(parent)
|
|
{
|
|
setFocusPolicy(Qt::StrongFocus);
|
|
}
|
|
|
|
void SpinBoxIgnoreScroll::wheelEvent(QWheelEvent * event)
|
|
{
|
|
if (!hasFocus())
|
|
event->ignore();
|
|
else
|
|
QSpinBox::wheelEvent(event);
|
|
}
|
|
|
|
void SpinBoxIgnoreScroll::leaveEvent(QEvent * event)
|
|
{
|
|
clearFocus();
|
|
}
|