The problem was that every child widget of the native widnow got it's own window descriptor (HWND), so, for example, if I hit the menubar, in nativeEvent I saw that the message had a different descriptor than the main window had.
This is what solved my problem:

QApplication a(argc, argv); a.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); //... CEventFilter e{ &w }; a.installNativeEventFilter(&e);