QWebView wait load



  • Hello all, i try to load some site, but
    @QObject::connect(&view,SIGNAL(loadFinished(bool)),&loop,SLOT(quit()));@
    does not work (slot never calls, but site displayed correclty). It's truble of the site (other sites loads successfully). How I can fix it? Probably, I can use timer or content length fixer, but it is not a variant
    Thanks


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    With only that line of code it's very difficult to find what could be wrong. Did you start your loop ? What version of Qt are you using ? On what OS ?



  • Yes, I start. I use qt 4.7, win xp os.
    I resolve it via QNetworkRequest (use get and post requests and setHtml method). But if it possible, I want to get answer about this question


  • Lifetime Qt Champion

    You don't give any example of which site are working, which are not and how you are coding your stuff.

    Without anything, nobody can answer the question



  • It not work
    @ QWebView view;
    view.show();
    QEventLoop loop;
    QObject::connect(&view,SIGNAL(loadFinished(bool)),&loop,SLOT(quit()));
    view.load(QUrl("https://www.paypal.com/us/home"));
    loop.exec();
    ::Beep(1000,1000);@

    It work
    @ QWebView view;
    view.show();
    QEventLoop loop;
    QObject::connect(&view,SIGNAL(loadFinished(bool)),&loop,SLOT(quit()));
    view.load(QUrl("https://tools.usps.com/"));
    loop.exec();
    ::Beep(1000,1000);@

    I wanna say what in first variant I hear beep, in second no



  • Some ideas?


  • Lifetime Qt Champion

    Did you check that the not working link really does something ? i.e. using loadProgress



  • No, but i see load process in window-browser, it works. And if i use QNetworkAccessManager it works too



  • You should wait longer...
    according to a wireshark it takes approx. 3.5 minutes for WebKit to load that page
    see my timestamps:
    19 2013-06-04 15:03:24.887647000 10.68.2.42 198.143.168.230 HTTP 256 CONNECT www.paypal.com:443 HTTP/1.1
    ... and ~2000 packets later
    1904 2013-06-04 15:06:40.434697000 198.143.168.230 10.68.2.42 SSL 93 Continuation Data
    1905 2013-06-04 15:06:40.434761000 10.68.2.42 198.143.168.230 TCP 54 56650 > ndl-aas [RST, ACK] Seq=218 Ack=40 Win=0 Len=0
    and here it beeps!

    the line 1904 says
    Proxy-Connect-Hostname: www.paypal-search.com
    Proxy-Connect-Port: 443
    just before RST

    so it works thru QNetworkRequest, QNetwokManager because it just loads main web page not trying to resolve anything while QWebView works like a browser and tries to resolve everything on that page and to render it as a real browser

    as to why it takes longer - there could be problems with secure connections, certificates etc. to different domains linked on that page: t.paypal.com, search-paypal.com etc.

    My guess - try to open every ..well at least one link per domain name using QNetwokManager to see where it fails. Solution might require to manually add some certificates on Windows

    That's a common issue with QtWebKit ...
    a few pointers
    http://qt-project.org/forums/viewthread/15949/
    http://qt-project.org/forums/viewthread/19690
    http://stackoverflow.com/questions/8362506/qwebview-qt-webkit-wont-open-some-ssl-pages-redirects-not-allowed
    HTH

    P.S. I am using Qt 5.0.2 default install with MSVS 2010. I never experienced these on linux where openssl is much better integrated



  • Oh, yes. So, how I can check only main page? I need only it

    P.S. I was read these topics and found the resolution (resolution of ssl trouble, not above question!):
    @QSslConfiguration sslCfg = QSslConfiguration::defaultConfiguration();
    sslCfg.setPeerVerifyMode(QSslSocket::VerifyNone);
    QSslConfiguration::setDefaultConfiguration(sslCfg);@



  • If you need just raw webpage then use QNetworkRequest with QNetworkAccessManager
    but if you want to use e.g. some CSS selectors on QWebPage then you could try to disable as much functionality as possible from webkit and use QWebPage or QWebFrame...

    @ QWebSettings * globalSettings = QWebSettings::globalSettings();
    globalSettings->setAttribute(QWebSettings::AutoLoadImages, false);
    globalSettings->setAttribute(QWebSettings::JavascriptEnabled, false);
    globalSettings->setAttribute(QWebSettings::JavaEnabled, false);
    globalSettings->setAttribute(QWebSettings::PluginsEnabled, false);
    globalSettings->setAttribute(QWebSettings::JavascriptCanOpenWindows, false);
    globalSettings->setAttribute(QWebSettings::JavascriptCanCloseWindows, false);
    globalSettings->setAttribute(QWebSettings::JavascriptCanAccessClipboard, false);
    globalSettings->setAttribute(QWebSettings::DeveloperExtrasEnabled, false);
    globalSettings->setAttribute(QWebSettings::SpatialNavigationEnabled, false);
    globalSettings->setAttribute(QWebSettings::PrintElementBackgrounds, false);
    @

    That reduced wait time for me from 3m 30s to less than 10 seconds
    Not sure though how much of underlying DOM will be rendered correctly...
    HTH



  • Oh yeah, its work! Thank you!
    Is it was a bug of paypal site or my?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.