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



_______________________________________________
webkit-qt mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-qt

Reply via email to