问题
If we put a webpage in resources, how can we load it in webkit?
回答1:
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.
来源:https://stackoverflow.com/questions/8020569/how-to-load-a-web-page-from-resources-in-qt