QCalendarWidget - how to stop wheel events processing?
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:
Code:
QObject* view
= calendar
->findChild<QTableView
*>
("qt_calendar_calendarview");
view->installEventFilter(this);
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:
Code:
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.
Re: QCalendarWidget - how to stop wheel events processing?
Install the event filter on the view's viewport.
Re: QCalendarWidget - how to stop wheel events processing?
It worked! Thanks!
Do you know any other way to accomplish this without using findChild() with hard-coded object name?