将QwebView中的链接在系统默认浏览器中打开
QT代码:
m_WebView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
connect(m_WebView, SIGNAL(linkClicked(const QUrl&)), this, SLOT(slotOpenADsUrl(const QUrl&)));
。。。。略过上亿行。。。。。
void MainWindow::slotOpenADsUrl(const QUrl &url)
{
QString str = url.toString();
QDesktopServices::openUrl(url);
}
html代码:
<html>
<body style="padding:0; margin:0;">
<script>
function OpenNewWindow()
{
window.open('http://www.xxxx.com/xxxx.html?utm_source=client&utm_medium=banner&utm_content=xxxx&utm_campaign=multiple%2Bdesktops');
}
</script>
<div align="center"><a href="#" onclick="OpenNewWindow()"><img src="./images/xxxx.jpg" height="100%" border="0"/></a></div>
</body>
</html>
问题:
点击Qwebview中的图片后,slotOpenADsUrl中得到的的url链接是本地html地址加#,而不是我想要的onClick中的链接,查了很多资料,也不没弄清这是什么原因?有什么解决办法么?谢谢!