tags:

views:

290

answers:

1

Hi,

In Qt WebKit you can call QWebFrame.renderTreeDump() to see the render tree. For images in html

<img src=...>

you get something like:

RenderImage {IMG} at (0,0) size 174x71

However, there is no render information for images loaded from ccs (backgrounds etc). Is there a way to access these? I'd also like to be get the urls of loaded images too.

Thanks

A: 

I just started exploring QT/WebKit for work; in version 4.6 they have expanded considerably the API, it's now possible to access the DOM of a loaded document. The QWebElement class has a styleProperty getter that allows you to read the corresponding CSS property. For reading e.g. the background image of the body:

QWebElement body = main_frame->findFirstElement("body");
QString img = body.styleProperty("background-image", QWebElement::ComputedStyle);

For the full API see QtWebKit Module reference documentation.

Luca Tettamanti
ok great, I'll check it out. I'm actually in a Java environment and using jambi. I understand that they're not continuing with development of jambi beyond 4.5, which is annoying, as it's pretty damn good.
Richard
Oh, I totally missed the "Java" tag; unfortunately the DOM API has been introduced in QT 4.6...
Luca Tettamanti