1

I intend to replace QT webkit with OSX native webkit in a QT based application, what I did right now is making an QT control inherited from QMacCocoaViewContainer and embed a cocoa web view in it. It could show the page correctly, but cocoa web view can't receive mouse moved event, so the js/css hover effect can't be shown. I tried to compare it with native cocoa Application, and found that cocoa web view could get NSMouseMovedNotifcation from notification center in native cocoa App, but QT app builds its own event loop and send event with its own strategy, this notification isn't received.

Who can tell me how to fix it? Any comments are very appreciated.

QTWebView(QWidget *pparent): QMacCocoaViewContainer(0, pparent)
{
    ...
    xwebview = [[WebView alloc] init];
    setCocoaView(xwebview);
    NSString *urldefault = @"http://www.google.com";
    [[xwebview mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urldefault]]];
    ...
}
Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72

1 Answers1

0

I was having a similar issue and I resolved it by implementing the macEvent(EventHandlerCallerRef, EventRef) function. Create an NSEvent from the eventRef

NSEvent* nsEvent = [NSEvent eventWithEventRef:event];

If the event is a MouseMoved event then send a mouseMoved: event to the NSView where the NSView is (NSView*)winId().

I hope this helps

  • Thank you! But how did you send the mouse moved event, I tried below codes, it doesn't work: NSView* webView = (NSView*)this->winId(); [webView mouseMoved:nsEvent]; – user2566639 May 14 '13 at 04:04
  • right now, my solution is posting a provide mousemoved notification from default notification center. It works, but as you know, this is a private notification which is not suggested by Apple. [[NSNotificationCenter defaultCenter] postNotificationName:@"NSMouseMovedNotification" object:nil userInfo:xxx]; – user2566639 May 14 '13 at 04:08