SOFA API  6a688117
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

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

Function details

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