BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
WheelEventEater Class Reference

Description

Event filter to install on combo boxes and spin boxes to not to react on wheel events during scrolling of InstrumentComponentWidget.

Definition at line 34 of file CustomEventFilters.h.

Inheritance diagram for WheelEventEater:
[legend]
Collaboration diagram for WheelEventEater:
[legend]

Public Member Functions

 WheelEventEater (QObject *parent=nullptr)
 

Static Public Member Functions

static void install (QObject *obj)
 

Protected Member Functions

bool eventFilter (QObject *obj, QEvent *event) override
 

Constructor & Destructor Documentation

◆ WheelEventEater()

WheelEventEater::WheelEventEater ( QObject *  parent = nullptr)

Definition at line 41 of file CustomEventFilters.cpp.

42  : QObject(parent)
43 {
44 }

Referenced by install().

Member Function Documentation

◆ eventFilter()

bool WheelEventEater::eventFilter ( QObject *  obj,
QEvent *  event 
)
overrideprotected

Definition at line 52 of file CustomEventFilters.cpp.

53 {
54  if (auto* spinBox = qobject_cast<QAbstractSpinBox*>(obj)) {
55  if (event->type() == QEvent::Wheel) {
56  if (spinBox->focusPolicy() == Qt::WheelFocus) {
57  event->accept();
58  return false;
59  }
60  event->ignore();
61  return true;
62  }
63  if (event->type() == QEvent::FocusIn)
64  spinBox->setFocusPolicy(Qt::WheelFocus);
65  else if (event->type() == QEvent::FocusOut)
66  spinBox->setFocusPolicy(Qt::StrongFocus);
67  } else if (qobject_cast<QComboBox*>(obj)) {
68  if (event->type() == QEvent::Wheel) {
69  event->ignore();
70  return true;
71  }
72  event->accept();
73  return false;
74  }
75  return QObject::eventFilter(obj, event);
76 }

◆ install()

void WheelEventEater::install ( QObject *  obj)
static

Definition at line 46 of file CustomEventFilters.cpp.

47 {
48  auto* p = new WheelEventEater(obj);
49  obj->installEventFilter(p);
50 }
WheelEventEater(QObject *parent=nullptr)

References WheelEventEater().

Referenced by InterferenceForm::InterferenceForm(), MesoCrystalForm::createBasisCombo(), GUI::Util::createSelectionCombo(), and AbstractSelectionContainerForm::initUI().

Here is the call graph for this function:

The documentation for this class was generated from the following files: