Hi, all! 
     This is my code(get content of dynamic page,load page from local file 
system,include all of the resource, and ouput )

class Nam: public QNetworkAccessManager 
{
    Q_OBJECT
protected:
    virtual QNetworkReply* createRequest(Operation op, const QNetworkRequest & 
req, QIODevice * outgoingData = 0) 
    {
        QString path;
        ......//convert the url of req to the path of the resource in the local 
file system
        QNetworkRequest newReq(req);
        QUrl url(path);
        newReq.setUrl(url);
        return QNetworkAccessManager::createRequest(op, newReq, outgoingData);
    }
};
class WebCapture : public QObject
{
    Q_OBJECT
public:
    WebCapture();
    void get(); 
signals:
    void finished();
private slots:
    void saveResult(bool ok); 
private:
    Nam nam;
    QWebPage m_page;
};
WebCapture::WebCapture(): QObject()
{
    m_page.setNetworkAccessManager(&nam);
    connect(&m_page, SIGNAL(loadFinished(bool)), this, SLOT(saveResult(bool))); 
} 
void WebCapture::get()
{ 
    QString content;
     ......//read html code from local file system
     QUrl url("http://blog.people.com.cn";);//base url of the page
     m_page.mainFrame()->setHtml(content, url);
     return ;
}
void WebCapture::saveResult(bool ok)
{
    if (!ok) 
    {
        emit finished(); 
        return; 
    }
    qDebug() << m_page.mainFrame()->toHtml();
    emit finished();
}
int main(int argc, char* argv[])
{
    QApplication a(argc, argv);
     WebCapture wc;
     QObject::connect(&wc, SIGNAL(finished()), QApplication::instance, 
SLOT(quit()));
     wc.get;
     return a.exec();
}
In average,parse a page need 140ms, but 130ms is spend on a.exec(),so, i have 
two question:
1) Is there any way to avoid call QApplication::exec(),because it's 
time-consuming.
2) When i call a.exec(), does the rendering progress is called??I don't need to 
layout this page.

        Zhou Peng
        [email protected] 
          2011-03-16 
_______________________________________________
webkit-qt mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-qt

Reply via email to