View Full Version : QCalendarWidget - how to stop wheel events processing?

2nd July 2013, 23:24
For most widgets I can disable mouse wheel events by installing events filter. It doesn't work for QCalendarWidget.
It works for months/years scrolling (on the header), but when I scroll on top of actual calendar view (the table view), the scrolling is processed anyway.

How to disable it?

I tried to get into the QTableView that is rendering the calendar by using:

QObject* view = calendar->findChild<QTableView*>("qt_calendar_calendarview");
I know it's an ugly hack to workaround the "private d pointer" pattern, but it was my only hope, since QCalendarWidget doesn't allow to do anything with the calendar view widget inside of it (which I find inconvenient). The filter I'm installing is implemented like this:

bool MultiEditorDateTime::eventFilter(QObject* obj, QEvent* event)
if (event->type() == QEvent::Wheel)
return true;

return MultiEditorWidget::eventFilter(obj, event);
I even stopped in debug to see if the filter gets any events and indeed it does, but not the Wheel events. I wonder - what object does receive the wheel events?

This method works fine for other widgets, like QComboBox or QTextEdit. I have problem only with QCalendarWidget (so far). Any hints?

I'm using Qt 5.0.1.

3rd July 2013, 07:53
Install the event filter on the view's viewport.

3rd July 2013, 23:06
It worked! Thanks!

Do you know any other way to accomplish this without using findChild() with hard-coded object name?