[webkit-qt] load iframe
Zhou Peng
zhoupeng19 at 126.com
Mon Feb 13 21:57:50 PST 2012
Hi!
I'm trying to get the contents and src of every iframe in web page. This is my code:
class myclass : public QObject
{
......
myclass()
{
......
QObject::connect(page_, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool)), Qt::QueuedConnection);
QObject::connect(page_, SIGNAL(frameCreated(QWebFrame*)), this, SLOT(frameCreated(QWebFrame*)), Qt::QueuedConnection);
}
download(QUrl url)
{
...
frames_ = 0;
finished_ = false;
page_->mainFrame()->load(url);
while (!finished_)
qApp->processEvents(QEventLoop::WaitForMoreEvents | QEventLoop::AllEvents);
......
}
public slots:
void frameCreated(QWebFrame* frame)
{
......
++frames_;
QObject::connect(frame, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool)), Qt::QueuedConnection);
}
void loadFinished(bool ok)
{
......
--frames_;
if(frames_ == 0)
{
finished_ = true;
}
}
private:
int frames_;
QWebPage* page_;
bool finished_;
};
When I load page which contain many iframe, “frames_” will never reach 0, because in some frame, loadFinished signal isn’t be catch,why?
Sorry for my poor english!
Zhou
2012.2.14
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-qt/attachments/20120214/45dfc703/attachment.html>
More information about the webkit-qt
mailing list