问题
I got a problem with QWebPage::loadFinished (bool) signal , it calls back twice , is that normal ? ( there's no link following at all , e.g HTTP status 302 )
Consider the following code , the whole thing may cause problem , is trying to load another link within that slot , will this be a problem ?
If i do a qDebug() << thisUrl;
each time in loadFinished(bool)
slot , i could see it for 3 times , is that normal , one for url XXX
, and 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:
im seeing this too with qt 4.7.4 (with phantomjs). i used the frame's loadFinished instead of the page's and it isn't sent twice.
来源:https://stackoverflow.com/questions/8415289/signal-qwebpageloadfinishedbool-returns-twice