Important: Please read the Qt Code of Conduct -

How to click on WebView Link Programatically and load resultant page in same WebView

  • Hello All,

    In my QT application I am using QWebView for loading any webpage and getting their source code on LoadFinished slot.
    First web page is containing link of Next Page,so now I want to click on that Next Page link via code
    and that next page should be load in same webview so that I can get source code of that page again.

    Please give any suggestion or solution.Attaching code would be more helpful for me.

    Thanks in Advance


  • Clicking the link is simply sending the request to the server, you even do not need WebKit for that. "QNetworkAccessManager": will be enough.

  • But if you need webview, then simply find needed link in finished slot and call webview->load with found link as an argument.

  • Or you can use JavaScipt to do it:

    @mainFrame()->evaluateJavaScript(“\nvar evt = document.createEvent('Event');\nevt.initEvent('click',true,true);\ndocument.getElementsByTagName(\‘a\’)[0].dispatchEvent(evt);”);@

Log in to reply