No, here must be it. What class is the main window? Is it QWidget or QMainWindow?
Because you should call QMainWindow::eventFilter not QWidget.

And the common practice is to test first for the target object and then for the event type, not the other way around. Take a look at the eventFilter documentation. There is an example there.

Regards