|
一.首先,讓我們展示一幅QWebView的網(wǎng)頁效果圖: 想要實(shí)現(xiàn)上面的效果很簡單,你只需要完成三個(gè)步驟 1.建立一個(gè)QWebView對(duì)象,QWebView *view = new QWebView(parent);其中parent為父類.如果想要QWebView為top window,可以設(shè)置parent = 02.調(diào)用load或setUrl方法設(shè)置要顯示的網(wǎng)頁.注意網(wǎng)頁的格式以http://開頭3.調(diào)用show方法顯示QWebView 完整的代碼為:QWebView *view = new QWebView(parent); //步驟1view->load(QUrl("http:///")); //步驟2view->show(); //步驟3
二.QWebView除了用load方法設(shè)定網(wǎng)頁路徑外,也可以使用setHtml方法加載html格式的網(wǎng)頁,這里我們以加載google地圖插件為例.最后的效果圖為:
2.獲取到得代碼為:<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"src="http://ditu.google.cn/maps?hl=zh-CN&q=%E5%9C%B0%E5%9B%BE&ie=UTF8&brcurrent=3,0x31508e64e5c642c1:0x951daa7c349f366f,0%3B5,0,0&ll=38.005263,115.357367&spn=15.390188,22.535491&output=embed"></iframe><br /><small><a href="http://ditu.google.cn/maps?hl=zh-CN&q=%E5%9C%B0%E5%9B%BE&ie=UTF8&brcurrent=3,0x31508e64e5c642c1:0x951daa7c349f366f,0%3B5,0,0&ll=38.005263,115.357367&spn=15.390188,22.535491&source=embed" style="color:#0000FF;text-align:left">查看大圖</a></small>我們可以刪去br、small和a標(biāo)記,最后在代碼前后添加<html></html>標(biāo)記將文件保存為*.html(注:刪除的部分為屏蔽google地圖的右鍵效果,可以保留)3.調(diào)用QWebView的setHtml方法設(shè)定上述文件的路徑,然后用show方法顯示google地圖本文來自CSDN博客,轉(zhuǎn)載請(qǐng)標(biāo)明出處:http://blog.csdn.net/chuckGao/archive/2009/08/26/4487157.aspx |
|
|