SOFA API  b3f2f2a4
Open source framework for multi-physics simuation
sofa::gui::qt::QMouseWheelAdjustmentGuard Class Reference

#include <QMouseWheelAdjustementGuard.h>

Filter qt events to allows wheel event to only be accepted when the widget has focus. More...

Inheritance diagram for sofa::gui::qt::QMouseWheelAdjustmentGuard:

Detailed Description

Filter qt events to allows wheel event to only be accepted when the widget has focus.

To use it you need to do: myWidget->setFocusPolicy(Qt::StrongFocus); myWidget->installEventFilter(new MouseWheelWidgetAdjustmentGuard(ui.comboBox));

This code is grabbed from: https://stackoverflow.com/questions/5821802/qspinbox-inside-a-qscrollarea-how-to-prevent-spin-box-from-stealing-focus-when

Public Member Functions

 QMouseWheelAdjustmentGuard (QObject *parent)
 

Protected Member Functions

bool eventFilter (QObject *o, QEvent *e) override
 

Constructor details

◆ QMouseWheelAdjustmentGuard()

sofa::gui::qt::QMouseWheelAdjustmentGuard::QMouseWheelAdjustmentGuard ( QObject parent)
explicit

Function details

◆ eventFilter()

bool sofa::gui::qt::QMouseWheelAdjustmentGuard::eventFilter ( QObject o,
QEvent *  e 
)
overrideprotected