QtWebEngine/Porting from QtWebKit
|This guide is work in progress. It will be updated together with the code in the master branch.|
En Ar Bg De El Es Fa Fi Fr Hi Hu It Ja Kn Ko Ms Nl Pl Pt Ru Sq Th Tr Uk Zh
This guide gives an overview of the differences between using the Qt WebKit and Qt WebEngine APIs in applications.
This guide intends to provide an overview of the steps to follow when porting an application using Qt WebKit's QWebView API to use Qt WebEngine's QWebEngineView.
The Qt WebEngine equivalent of Qt WebKit C++ classes are prefixed by QWebEngine instead of QWeb.
Most of QWebHitTestResult is now available in QWebEngineContextMenuData
Qt module name
In qmake project files
Including the module in source files
QWebFrame has been merged into QWebEnginePage
It is not possible to access sub-frames. Methods of the main QWebFrame are now available directly through the QWebEnginePage itself.
Some methods now return their result asynchronously
Because Qt WebEngine uses a multi-process architecture, calls to some methods from applications will return immediately, while the results should be received asynchronously via a callback mechanism. A function pointer, a functor, or a lambda expression must be provided to handle the results when they become available.
|Qt WebEngine (with a lambda function in C++11)|
|Qt WebEngine (with a functor template wrapping a member function)|
|Qt WebEngine (with a regular functor)|
Qt WebEngine does not interact with QNetworkAccessManager
Some classes of Qt Network like QAuthenticator were reused for their interface but, unlike Qt WebKit, Qt WebEngine has its own HTTP implementation and cannot go through a QNetworkAccessManager.
The signals and methods of QNetworkAccessManager that are still supported were moved to the QWebEnginePage class.
Notes about individual methods
|Qt WebEngine (with lambda expressions in C++11)|
setHtml and setContent (QWebEnginePage)
The QWebEnginePage::setHtml and QWebEnginePage::setContent methods perform asynchronously the same way as a normal HTTP load would, unlike their QWebPage counterparts.
Qt WebKit classes or methods in this list will not be available in Qt WebEngine.
Qt WebEngine is designed for being used with hardware acceleration. Because we could not support a web view class in a QGraphicsView unless it would be attached to a QGLWidget viewport, this feature is out of scope.
Qt WebEngine uses a a multi-process architecture and this means that any access to the internal structure of the page has to be done asynchronously, any query result must be returned through callbacks. The QWebElement API was designed for synchronous access and this would require a complete redesign.
There is no way to connect a signal to run C++ code when a link is clicked. However, link clicks can be delegated to the Qt application instead of having the HTML handler engine process them by overloading the QWebEnginePage::acceptNavigationRequest() function. This is necessary when an HTML document is used as part of the user interface, and not to display external data, for example, when displaying a list of results.
The Web SQL Database feature that this API was wrapping in QtWebKit was dropped from the HTML5 standard.
QWebPluginDatabase, QWebPluginFactory, QWebPluginInfo, QWebPage::setPalette, QWebView::setRenderHints
Qt WebEngine renders web pages using Skia and isn't using QPainter or Qt for this purpose. The HTML5 standard also now offers much better alternatives that were not available when native controls plugins were introduced in QtWebKit.
Visited links are persisted automatically by Qt WebEngine.