PDA

View Full Version : capture web contents with the qt webkit?



billconan
14th March 2009, 20:01
Hello guys,

I want to implement a feature in my program that captures the HTML code under where my mouse clicked. for example, if i loaded a webpage, and then i click my mouse on a picture on that page, i can capture the HTML of that picture: <img src="..." />, and if i press on a video, i can get an <embed ...> tag.

I'm just wondering if i can get this information from the webkit render. given a position on the rendered web page, can the webkit tell me which line of the HTML code was drawn at that place?

I also want to know that if i specify one line of HTML of a web page, can webkits tell me where that line of HTML will be rendered? and what size it would be?

Thank you.

wysota
14th March 2009, 21:59
I don't think it is possible directly with WebKit. You'd have to inject some javascript code into WebKit (which is possible) but I don't know if Javascript let's you operate on the DOM tree in a geometrical fashion.

Some things can be done by using QWebFrame::hitTestContent() but I don't see any way to retrieve information about what you actually clicked.

aamer4yu
15th March 2009, 05:42
You can check this example (http://labs.trolltech.com/blogs/2009/03/12/wysiwyg-html-editor/) on Qt labs. May be it helps you :)

billconan
20th March 2009, 01:17
You can check this example (http://labs.trolltech.com/blogs/2009/03/12/wysiwyg-html-editor/) on Qt labs. May be it helps you :)

thank you, but i guess, i have to look into the webkit feature to have this feature. the editor example is not what i want.