bool MainWindow::waitForLoad(QWebView& view)
{
QEventLoop loopLoad;
QTimer timer;
QObject::connect(&view, SIGNAL(loadFinished(bool)), &loopLoad, SLOT(quit()));
QObject::connect(&timer, SIGNAL(timeout()), &loopLoad, SLOT(quit()));
timer.start(timeout);
loopLoad.exec();
if(!timer.isActive())
{
timer.stop();
view.stop();
return false;
}
return true;
}
Say me, is that a correct code? App sometimes freezes after line
loopLoad.exec();
And always returns true even here has happened some problem (timeout, errors when loading, ect -- always true).