Please nominate your Qt Champions for 2021! https://forum.qt.io/topic/132134/looking-for-the-2021-qt-champions

Problem about QWebView



  • I use QWebView to show a url page and the Page is loaded successfully. But when i click the link in the page, this is no response. What should I do ?



  • Is it an ordinary link or some javascript? For the latter you need to enable [removed]

    @
    QWebSettings *ws = QWebSettings::globalSettings();
    ws->setAttribute(QWebSettings::JavascriptEnabled, true);
    ws->setAttribute(QWebSettings::JavascriptCanOpenWindows, true);
    @



  • Thanks for your reply. Actually it is a ordinary url.The website url I tested is "http://www.csdn.net", I can not click any link in this page.



  • The site works entirely on javascript - I think you never looked at the source code.

    The javascript methods open separate windows all the time. You will need to look into createWindow methods of [[Doc:QWebView]] and/or [[Doc:QWebPage]]. The default implementations do nothing, this is the reason why you do not see anything. If you load an ordinary page like http://google.com/ everything works as expected.



  • Thanks for your answer. You are really a nice man.
    According to your advice, I subclass the QWebPage and override the createWindow() function. Then it works perfectly!

    Thanks again!


Log in to reply