[webkit-qt] get page content

周鹏 zhoupeng19 at 126.com
Tue Mar 8 01:06:25 PST 2011


Hi,guys! 
    I want to get the page content after all external resource is loaded,but i don't want to call the QApplication::exec() function,is it possible(because this function open a window,but i don't need it,all i want is the content of the page)?this is my code:

class View : public QWebView
{
    Q_OBJECT
public:
    View(QWidget *parent = 0); 
private slots:
    void loadFinished(bool ok);
};
View::View(QWidget *parent) : QWebView(parent)
{
    setUrl(QUrl("http://blog.people.com.cn/blog/c3/s3328,w1299523481642728"));
    connect(this, SIGNAL(loadFinished(bool)), SLOT(loadFinished(bool)));
}
 
void View::loadFinished(bool ok)
{
    Q_UNUSED(ok);
    QWebFrame *frame = page()->mainFrame();
    qDebug() << frame->toHtml();//output
}
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);   
    View view;
    view.show();
    return app.exec();
}

In other words,i want to delete the last line of code in main function,but i need the program work correctly,is it possible?If yes,how can i do it?



        Zhou Peng
        zhoupeng19 at 126.com 
          2011-03-08 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-qt/attachments/20110308/0012644c/attachment.html>


More information about the webkit-qt mailing list