Javascript call function QWebView

I am trying to connect a called QAction signal () with a JS function in a QWebView. So my code is:

... QWebView *webView = new QWebView; QAction *buttonAction = new QAction; webView->load(QUrl(":/example.html"); ... connect(buttonAction, SIGNAL(triggered()), this, SLOT(alert())); ... 

Slot function:

 void MainWindow::alert() { webView->page()->mainFrame()->evaluateJavaScript(QString("myFunction();")); } 

In example.html:

 <script type="text/javascript"> function myFunction() { alert("I am an alert box!"); } </script> 

So, the application starts normally, but when I click the button, the application crashes with an error, and does not display a warning. In addition, there is a message in debugging:

 QWaitCondition: Destroyed while threads are still waiting 

What's the matter?

+4
source share

All Articles