ui->webView->load(QUrl("http://www.baidu.com"));
ui->webView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
voidMainWindow::on_webView_linkClicked(constQUrl&arg1)
{
ui->webView->load(QUrl("http://www.qq.com"));
QMessageBoxhimessagebox;
himessagebox.setText("hitodayisaniceday");
himessagebox.exec();
}
QStringfilename=QFileDialog::getOpenFileName(this,tr("打开文件..."),QString(),tr("网页文件(*.htm*.mht*.html);;AllFiles(*.*)"));
if(!filename.isEmpty())
{
ui->webView->settings()->setAttribute(QWebSettings::PluginsEnabled,true);
ui->webView->settings()->setAttribute(QWebSettings::JavascriptEnabled,true);
ui->webView->page()->setPluginFactory(newIntelliPlugin);
ui->webView->load(QUrl::fromUserInput(filename));
QStringcurFile=QFileInfo(filename).canonicalFilePath();
this->setWindowTitle(curFile+"-WebView");
}
ui.webView->page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal,Qt::ScrollBarAlwaysOff);
ui.webView->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical,Qt::ScrollBarAlwaysOff);
ui.webView_2->page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal,Qt::ScrollBarAlwaysOff);
ui.webView_2->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical,Qt::ScrollBarAlwaysOff);
Qt.openUrlExternally("http://yoururl")
Qt.openUrlExternally("tel:<number>")
QDesktopServices::openUrl(arg1);
qt 调用html页面的javascript
ui.webView->page()->mainFrame()->evaluateJavaScript("helloworld()");
ui.webView->page()->setContentEditable(true);
ui.webView->page()->triggerAction(QWebPage::Paste,true);