Example code for a simple web page browser using WebKit QT in C++

僤鯓⒐⒋嵵緔 提交于 2019-12-03 08:12:12

Your requirement is still not scoped enough. If you want the simplest possible full application example which displays a web page, here is the code:

#include <QtGui>
#include <QtWebKit>

int main(int argc, char** argv) {
    QApplication app(argc, argv);
    QWebView view;
    view.show();
    view.setUrl(QUrl("http://google.com"));
    return app.exec();
}

If that is example.cpp, you can use the following example.pro:

QT += webkit
SOURCES = example.cpp

The easiest way to Qt development is using Qt Creator and you can load that .pro file with Qt Creator, build the app, and launch it. There is only one window (QWebView instance) and it will open Google homepage.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!