Building QtWebKit Technology Preview 5 from Sources

Updates for the QtWebKit module were dropped by the Qt Company after switching to the Blink-/Chrome-based QtWebEngine module. After years of development, there is still a lack of features that where available in the original QtWebKit module.

Because of different reasons, some guys started to update the QtWebKit module with fresh code from the WebKit repositories. What you don't expect: WebKit is really alive and has implemented a bunch of new web features.

Last week, the Technical Preview 5 was released [1]. It should be compatible with any recent Qt5 version, in the following chapters you will see how to build it from source or how to use the pre-built binaries for Qt5.8.

1. Build QtWebKit TP5 from sources
1.1. download & extract QtWebKit TP5 sources
The release page of QtWebKit TP5 contains the source code package for building the module by yourself. Download it [2].

On Mac  & Linux, extract the sources and change to the directory:
$ tar xf qtwebkit-tp5.tar.xz
$ cd qtwebkit-tp5

1.2. build & install
After downloading and extracting the sources, run qmake & then build QtWebKit:
$ <path-to-your-qt-installation>/bin/qmake
$ make -j<number-of-cpu-cores>
Go, get some coffee and wait some time. Afterwards, you have to install the module into your Qt installation:
$ make install

2. Use the pre-built QtWebKit TP5 modules with Qt5.8
Users with an installation of Qt5.8 from the official binary installers can make use of the pre-built packages of QtWebKit TP5. Konstantin Tokarev is providing packages for MacOS (does not work with the ), Linux x64 and Windows (MinGW 5.3, MSVC2016 x86/x64) [3].

For MacOS, you download qtwebkit-tp5-qt58-darwin-x64.tar.xz. Extract it with:
$ tar xf qtwebkit-tp5-darwin-x64.tar.xz
The pre-built package containing 3 folders with the needed QtWebKit headers and libraries. Copy them to your Qt5.8 installation:
$ cd qtwebkit-tp5-qt58-darwin
$ cp -r include lib mkspecs <path-to-your-qt-installation>
Now, you are ready to use QtWebKit TP5!

Workaround for users of Xcode
With QtWebKit TP5, I run into the problem that I got linker errors like the following:

ld: library not found for -lQt5WebKitWidgets
Right now, I didn't identified the root cause but you can work around this issue by changing the following files accordingly (right before the "QT_MODULES += ..."):

# <path-to-your-qt-installation>/mkspecs/modules/qt_lib_webkit.pri

QT.webkit.module = QtWebKit
QT.webkit.module_config = v2 lib_bundle

# <path-to-your-qt-installation>/mkspecs/modules/qt_lib_webkitwidgets.pri

QT.webkitwidgets.module = QtWebKitWidgets
QT.webkitwidgets.module_config = v2 lib_bundle
Afterwards, re-run qmake for your application (if needed) and re-build the application!

Try a simple QtWebKit example application
Now we want to try out a simple example application which is using QtWebKit. A good starting point is the facnybrowser application of the old QtWebKit examples.

Checkout out the git repository
$ git clone https://github.com/qt/qtwebkit-examples.git
$ cd qtwebkit-examples
or directly download the current source code and extract it
$ wget https://github.com/qt/qtwebkit-examples/archive/dev.zip
$ tar xf qtwebkit-examples-dev.zip
$ cd qtwebkit-examples-dev

Change to the right directory & build:
$ cd examples/webkitwidgets/fancybrowser
$ <path-to-your-qt-installation>/bin/qmake
$ make
Run the application:
$ ./fancybrowser
or on MacOS:
$ ./fancybrowser.app/Contents/MacOS/fancybrowser

After some moments, you should see the Qt developer homepage coming up:


Kommentare

  1. I copied qtwebkit-tp5-qt58-darwin folder ..
    How can apply on Qt creator?
    # /mkspecs/modules/qt_lib_webkit.pr

    AntwortenLöschen

Kommentar veröffentlichen

Beliebte Posts aus diesem Blog

Using QtOpenCL with Qt5

Native Look-and-Feel on Windows 10 Mobile with Qt / QML