如何从Qt中的资源加载网页? [英] How to load a web page from resources in Qt?
本文介绍了如何从Qt中的资源加载网页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我们在资源中放置一个网页,我们如何在webkit中加载它? 我不知道if我理解正确,但我想你有一个像test.html文件的网页,并且你希望它被加载到QWebView中。这很简单:
#include #include< QWebView>
int main(int argc,char * argv [])
{
QApplication a(argc,argv);
QWebView视图;
view.setUrl(QUrl(qrc:/test.html));
view.show();
返回a.exec();
}
文件必须放在Qt资源文件中。请记住添加:
QT + = webkit
添加到.pro文件中。
If we put a webpage in resources, how can we load it in webkit?
解决方案
I don't know if I understood correctly, but I suppose you have a web page like a test.html file, and you want it to be loaded in a QWebView. This is quite simple:
#include <QtGui/QApplication>
#include <QWebView>
int main(int argc, char* argv[])
{
QApplication a(argc, argv);
QWebView view;
view.setUrl(QUrl("qrc:/test.html"));
view.show();
return a.exec();
}
The file has to be placed in a Qt resource file. Remember to add:
QT += webkit
to your .pro file.
这篇关于如何从Qt中的资源加载网页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文