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

    Zain



  • Clicking the link is simply sending the request to the server, you even do not need WebKit for that. "QNetworkAccessManager":http://qt-project.org/doc/qt-5.0/qtnetwork/qnetworkaccessmanager.html 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
 

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