webkit-qt,你好!
Hi guys!
I want to get the page's layout infomation.eg:if there is a image in the
page,i want to know the coordinates of the image in the page,the background
color, for text,i want to know it's font,size,and it's coordinates...
here is my code:
//traversal a dom tree
void traversal(QWebElement node)
{
...
QRect rect= node.geometry();
printf("Start: X-%d,Y-%d End: X-%d,Y-%d\n", ss.topLeft().x(),
ss.topLeft().y(), ss.bottomRight().x(), ss.bottomRight().y() );
...
}
int main(int argc, char *argv[])
{
...
QString content(htmlSource);
QUrl url("file:///home/rmss/zp/");
QApplication a(argc, argv);
QWebView *view = new QWebView;
QWebSettings * settings = QWebSettings::globalSettings();
//settings->setAttribute(QWebSettings::AutoLoadImages, false);
settings->setAttribute(QWebSettings::JavascriptEnabled, false);
settings->setAttribute(QWebSettings::JavaEnabled, false);
settings->setAttribute(QWebSettings::PluginsEnabled, false);
settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, true);
settings->setDefaultTextEncoding("GB2312");
view->setHtml(content, url);
view->show();
QWebPage* page = view->page();
QWebFrame* frame = page->mainFrame();
QString str = frame->renderTreeDump();
QWebElement document = frame->documentElement();
QWebElement body = document.findFirst("body");
if(body .isNull())
{
printf("failed!\n");
return -1;
}
QString info = eee.styleProperty("background-color",
QWebElement::ComputedStyle);//get background color
traversal(body );
return 0;
}
I use "geometry" to get the location of every node,but it's not work
correctly,and this program can't process page which use external css. And
please tell me how to get the font,size of text.I have not much time to read
the qtwebkit code because my boss want me to fininsh this job in two days. So.
please tell me how to solove these problem,and if possible,give me some demo.
Apologize for my poor english!
周鹏
[email protected]
2011-02-23
_______________________________________________
webkit-qt mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-qt