开发者

How to access images loaded from css in Qt Webkit (java)

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜