PDA

View Full Version : How to disable wheelEvent()



Markus
6th August 2010, 17:22
Dear All,

I want do disable the wheelEvent for QComboBox, QDoubleSpinBox, and QSpinBox. (They live inside a QWidget which itself lies in a QFrame).

I tried setFocusPolicy(Qt::ClickFocus or even Qt::NoFocus) but it does not make a difference. As soon as I am with the mouse over those objects the wheelEvent will manipulate them.

Any idea how to stop the wheelEvent without subclassing all the classes?

Thanks
Markus

Lykurg
6th August 2010, 17:34
Subclassing:cool: Or simply install an event filter on that widgets.

JacquesBaniaque
6th August 2010, 18:38
Like it was said install an event filter and handle (or simply not handle) Wheel events by yourself


void SomeClass::initializeStuff()
{
m_combo = new QComboBox(this);
m_combo->installEventFilter(this);
}

bool SomeClass::eventFilter(QObject *obj, QEvent *event)
{
if(event->type() == QEvent::Wheel && obj == m_combo)
{
qDebug() << "Wheel event blocked";
return true;
}
return false;
}

Markus
6th August 2010, 18:42
Danke!

the event filter works great