QT 5.1 MainWindow 与 QWebview 如何通信
时间:2014-05-18 19:46:42
收藏:0
阅读:454
解决它们之间的通信问题,需要在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 ); } |
评论(0)