[webkit-qt] Avoid painting and layout while loading a page

周鹏 zhoupeng19 at 126.com
Tue Mar 8 19:04:41 PST 2011


Hi,guys! 
   I get very slow load times on QtWebKit in Linux.Can any one could tell me how to avoid painting and layout while loading a page,I just need the page content,don't care layout infomation.This is my code:

class WebCapture : public QObject
{
     Q_OBJECT
public:
     WebCapture();
     void load(const QUrl &url); 
signals:
     void finished();
private slots:
      void saveResult(bool ok); 
private:
     QWebPage m_page;
};
WebCapture::WebCapture(): QObject()
{
     connect(&m_page, SIGNAL(loadFinished(bool)), this, SLOT(saveResult(bool))); 
} 
void WebCapture::load(const QUrl &url)
{
     m_page.mainFrame()->load(url); 
}
void WebCapture::saveResult(bool ok)
{
     if (!ok) 
    {
      std::cerr << "Failed loading " << qPrintable(m_page.mainFrame()->url().toString()) << std::endl;
      emit finished(); 
      return; 
    }
     qDebug() << m_page.mainFrame()->toHtml();
     emit finished();
}
#include "webcapture.moc"
int main(int argc, char * argv[])
{
     QUrl url("http://blog.people.com.cn/blog/c3/s3328,w1299523481642728");
     QApplication a(argc, argv);
     QWebSettings * settings = QWebSettings::globalSettings();
     settings->setAttribute(QWebSettings::AutoLoadImages, false);
     settings->setAttribute(QWebSettings::JavascriptEnabled, true);
     settings->setAttribute(QWebSettings::JavaEnabled, false);
     settings->setAttribute(QWebSettings::PluginsEnabled, false);
     settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, false);
     WebCapture capture;
     QObject::connect(&capture, SIGNAL(finished()), QApplication::instance(), SLOT(quit()));
     capture.load(url); 
     return a.exec();
}

        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/20110309/514c0e9c/attachment.html>


More information about the webkit-qt mailing list