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 )
{
page->mainFrame()->load ("YYY");
return;
}
if ( thisUrl matches YYY )
{
return;
}
}
};
source
share