QWebPage :: loadFinished (bool) signal returned twice?

I had a problem with the QWebPage :: loadFinished (bool) signal, it called back twice, is this normal? (there’s no link at all, for example, HTTP status 302)

Consider the following code: all this can cause problems, trying to load another link inside this slot, will this be a problem?

If I do a qDebug() << thisUrl;every time in the slot loadFinished(bool), I could see it 3 times, this is normal, one for url XXXand two for url YYY, and the last two links are exactly the same.

class Dummy
{
    public:
        Dummy() 
        { 
            page = new QWebPage(this);  
            connect (page , SIGNAL(loadFinished(bool)) , SLOT(loadFinished(bool)));
            page->mainFrame()->load ("XXX");
        }

    private:
        QWebPage *page;

    private slots:
        void loadFinished (bool ok)
        {
            if ( ! ok ) return;

            const QString & thisUrl = page->mainFrame()->url().toString();

            if ( thisUrl matches XXX )
            {
                // parse reply message of url XXX
                page->mainFrame()->load ("YYY");
                return;
            }

            if ( thisUrl matches YYY )
            {
                // parse reply message of url YYY
                return;
            }
        }
};
+1
source share
1 answer

im seeing this too with qt 4.7.4 (with phantoms). I used the loadFinished frame instead of the page, and it is not sent twice.

+4
source

All Articles