I tried running this but nothing happens.
void MainWindow::on_pushButton_2_clicked()
{
ui->webView->load(QUrl("javascript:alert('hello world')"));
}
But it works if i load javascript it from an html file.
<a href="javascript:alert('hello world');">Click here to say hi</a>
I know I can run javascript from an html file but, my question is how can i inject javascript to a webview using a button
Try QWebFrame::evaluateJavaScript().