[webkit-qt] Getting a QWebElement based on mouse position

Stefan Bogner sbogner at gmail.com
Wed Nov 23 13:39:02 PST 2011


Hi, 

I am trying to have a slightly adapted context menu in my QWebView according 
to what QWebElement the mousepointer is at.

My first idea was to use page()->frameAt( event->globalPos() ) to get the 
Frame and then findAllElements("*") in the returned frame, iterate through the 
list and return the one where hasFocus() == true.

Result: Segfault when calling frameAt. Always.

Ok, then I thought I might give page()->currentFrame() a shot. Well, this 
seems to kind of do what I want, but it's not exactly reliable (ie. the first 
time after the frame has been reloaded, it will always return the wrong 
WebElement). 

Now my hope is that there is some easier way to do this that I just haven't 
thought of (ie. page()->getWebElementAtPos( QPoint ) ;-) ). Well. Or something 
like that.

Thanks in advance for any pointers.

Cheers-
Stefan


More information about the webkit-qt mailing list