這里用到了ui提升部件的小方法,記得設置控件為Microsoft web browser,先看看效果:
用到ui里面的QAxWidget控件,用以下這個類來提升這個控件。
#include <ActiveQt/QAxWidget>#include "windows.h"class WebAxWidget : public QAxWidget{public:WebAxWidget(QWidget* parent = 0, Qt::WindowFlags f = 0): QAxWidget(parent, f){}PRotected:bool translateKeyEvent(int message, int keycode) const Q_DECL_OVERRIDE{if (message >= WM_KEYFIRST && message <= WM_KEYLAST)return true;elsereturn QAxWidget::translateKeyEvent(message, keycode);}};pro中添加相關庫:
QT += widgets axcontainer
其實重要代碼只有一行:
ui->webBrowser->dynamicCall("Navigate(const QString&)", url);
這里的url可以是網絡地址,也可以是實體html
可參考api開發文檔:http://lbsyun.baidu.com/index.php?title=uri/api/web#.E5.8D.8F.E8.AE.AE.E5.BD.A2.E5.BC.8F
新聞熱點
疑難解答