解决它们之间的通信问题,需要在mainwindow中添加
1
2
3
4
5
6
7
8
|
ui->webView->settings()->setAttribute(QWebSettings::JavascriptEnabled, true );
connect(ui->webView->page()->mainFrame(),SIGNAL(javaScriptWindowObjectCleared()), this ,SLOT(addJavaScriptObject()));
void
MainWindow::addJavaScriptObject()
{ ui->webView->page()->mainFrame()->addToJavaScriptWindowObject( "MainWindow" , this );
} |