@LTartarini I used the same example zip file and only had to tweak a little bit to make it run on Qt 5.15.2.
First they split up QObject::setEventFilter into setEventFilter and setNativeEventFilter. We need the latter one. This requires making the Mouse3DInput class a subclass of QAbstractNativeEventFilter
class Mouse3DInput : public QObject, public QAbstractNativeEventFilter { ... }
Now we have to move the implementation of the original bool Mouse3DInput::RawInputEventFilter(void* msg, long* result) function into the definition of the QAbstractNativeEventFilter::nativeEventFilter(const QByteArray &eventType, void *message, qintptr *result) override.
class Mouse3DInput : public QObject, public QAbstractNativeEventFilter {
Q_OBJECT
public:
Mouse3DInput(QWidget* widget);
~Mouse3DInput();
//we have to make it non static and public to match the virtual function
bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override;
...
}
//Mouse3DInput.cpp
bool Mouse3DInput::nativeEventFilter(const QByteArray &eventType, void *message, long *result) {
if (gMouseInput == 0)
return false;
MSG* msg = (MSG*)(message);
if (msg->message == WM_INPUT) {
HRAWINPUT hRawInput = reinterpret_cast<HRAWINPUT>(msg->lParam);
gMouseInput->OnRawInput(RIM_INPUT,hRawInput);
if (result != 0)
result = 0;
return true;
}
return false;
}
In the constructor we can use our new filter.
Mouse3DInput::Mouse3DInput(QWidget* widget) : QObject(widget) {
fLast3dmouseInputTime = 0;
InitializeRawInput((HWND)widget->winId());
gMouseInput = this;
qApp->installNativeEventFilter(this);
}