Qt WebKit學習筆記(3)—實戰QWebView–1

來源:互聯網
上載者:User

一.首先,讓我們展示一幅QWebView的網頁:

 

 

想要實現上面的效果很簡單,你只需要完成三個步驟

1.建立一個QWebView對象,QWebView *view = new QWebView(parent);其中parent為父類.如果想要QWebView為top window,可以設定parent = 02.調用load或setUrl方法設定要顯示的網頁.注意網頁的格式以http://開頭3.調用show方法顯示QWebView 完整的代碼為:QWebView *view = new QWebView(parent);        //步驟1view->load(QUrl("http://qtsoftware.com/"));   //步驟2view->show();  //步驟3 二.QWebView除了用load方法設定網頁路徑外,也可以使用setHtml方法載入html格式的網頁,這裡我們以載入google地圖外掛程式為例.最後的為:

 

 

 

 
1.第一步,我們通過google地圖擷取外掛程式的代碼。進入google地圖頁面,點選連結,擷取代碼

 
2.擷取到得代碼為:<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://ditu.google.cn/maps?hl=zh-CN&amp;q=%E5%9C%B0%E5%9B%BE&amp;ie=UTF8&amp;brcurrent=3,0x31508e64e5c642c1:0x951daa7c349f366f,0%3B5,0,0&amp;ll=38.005263,115.357367&amp;spn=15.390188,22.535491&amp;output=embed"></iframe><br /><small><a href="http://ditu.google.cn/maps?hl=zh-CN&amp;q=%E5%9C%B0%E5%9B%BE&amp;ie=UTF8&amp;brcurrent=3,0x31508e64e5c642c1:0x951daa7c349f366f,0%3B5,0,0&amp;ll=38.005263,115.357367&amp;spn=15.390188,22.535491&amp;source=embed" style="color:#0000FF;text-align:left">查看大圖</a></small>我們可以刪去br、small和a標記,最後在代碼前後添加<html></html>標記將檔案儲存為*.html(註:刪除的部分為屏蔽google地圖的右鍵效果,可以保留)3.調用QWebView的setHtml方法設定上述檔案的路徑,然後用show方法顯示google地圖

本文來自CSDN部落格,轉載請標明出處:http://blog.csdn.net/chuckGao/archive/2009/08/26/4487157.aspx

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.