PDA

View Full Version : How to follow a a href hyperlink?



ddz91
18th September 2013, 18:46
Hi all!

I've been searching the internet for how follow a <a href> hyperlink on Qt Webkit, and as I found nothing about it, I am now asking for help in this forum.

I've tested with this code:

void MainWindow::putPagina1()
{
QWebElement el = ui->webView->page()->mainFrame()->findFirstElement("a[href]");
el.evaluateJavaScript("this.click()");


}

The source code of the website is as follows:

<html>
<head>
</head>
<body>
<h1><a href="button1.html">Click here if you are button 1</a></h1>
<h1><a href="button2.html">Click here if you are button 2</a></h1>
</body>
</html>

The idea is this: when you press button1, the browser displays button1.html and when you press button2, the browser displays button2.html .

Thank you!