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

前端 未结 1 1510
深忆病人
深忆病人 2021-02-09 06:42

I have never used Qt and WebKit and now have a need to create a simple single web page browser using the Qt WebKit module. The application

相关标签:
1条回答
  • 2021-02-09 07:07

    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.

    0 讨论(0)
提交回复
热议问题