PDA

View Full Version : Inserting a link in webkit



mholmes
20th January 2012, 14:34
I'm building a basic editor widget using Webkit. The Qt bindings expose a large selection of editing actions through QWebPage::WebAction, but these don't include an action to create a link (<a href="whatever...">...</a>). However, I've found:

/qt/src/3rdparty/webkit/WebCore/editing/CreateLinkCommand.h

which seems to suggest that the underlying functionality is there in webkit, but I don't know how to make use of it. Does anyone have any suggestions or code examples showing how to do this?

Thanks,
Martin

wysota
20th January 2012, 14:41
You can modify the web page contents through QWebElement API.

mholmes
20th January 2012, 17:46
Do you know how I get access to the QWebElement(s) that contain the selection?

wysota
20th January 2012, 19:10
No, I don't. Look it up in the docs.

mholmes
30th January 2012, 14:26
I wouldn't post here if I hadn't already spent a lot of time with the docs. I don't see that there's any way to get access to the QWebElement(s) over which the selection ranges.

wysota
30th January 2012, 16:07
Maybe not directly. You probably have to go through QWebHitTestResult or similar so it boils down to checking in QtWebKit source code how to determine where the selection is. Maybe in the process you'll find an easier way of determining selection elements.