解决它们之间的通信问题,需要在mainwindow中添加
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);}