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
[email protected]
2011-03-08 _______________________________________________
webkit-qt mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-qt