I found a similar question in SO: Event related to embedding cocoa webview in a QT application that contains the answer. I can confirm that the solution in this answer works, but only hint. Here is what I did:
- Repeat the implementation of QApplication :: macEventFilter () in your application.
Disable other people's widgets for your application or only for QMacNativeCocoaWidget by doing
setAttribute(Qt::WA_PaintOnScreen)
In macEventFilter (), check if the event is a MouseMove event:
NSEvent *e = reinterpret_cast<NSEvent *>(event); if ([e type] == NSMouseMoved)
If so, check to see if the coordinates are within the boundaries of the WebView, and then send a MouseMoved notification to the Notification Center:
[[NSNotificationCenter defaultCenter] postNotificationName:@"NSMouseMovedNotification" object:nil userInfo:[NSDictionary dictionaryWithObject:e forKey:@"NSEvent"]];
When you check to see if the position of the event is in your WebView, remember that the coordinates of cocoa have the origin at the bottom, and in Qt (0, 0) the top left!
source share