[webkit-qt] How to use geometry function of QWebElement calss?

zhoupeng19@126.com zhoupeng19 at 126.com
Mon Feb 28 00:40:15 PST 2011


Hi guys! 
I want to implementation VIPS algorithm.So, I need to get the coordinates and size of the page elements.For example,in this page:www.google.com, there is one picture(logo),i want to know the location and size in the window after page rendering.And i want to get the coordinates of the text.
Here is my code,but it's doesn't work correctly:

void traversal(QWebElement node)
{ 
     QRect ss = node.geometry();
     printf("Tag Name:%s Start: X-%d,Y-%d  Size:%d\n", qPrintable(node.tagName()), ss.topLeft().x(), ss.size().width()*ss.size().height());
     ...//traversal the child node
     return ;
}

int main(int argc, char *argv[])
{
    QString content(source);
    QUrl url("file:///home/rmss/zp/1_files");
    QApplication a(argc, argv);
    QWebView *view = new QWebView;
    view->setHtml(content, url);
    view->show();
 
    QWebPage* page = view->page();
    QWebFrame* frame = page->mainFrame();
    QWebElement document = frame->documentElement();
    QWebElement body = document.findFirst("body");
    traversal(body);
    return 0;
}
Please tell me what's wrong of my program? Does geometry function satisfy my requirement?

        Zhou Peng
        zhoupeng19 at 126.com 
          2011-02-28 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-qt/attachments/20110228/5c9126e4/attachment.html>


More information about the webkit-qt mailing list