[Qtwebengine] Modifying request Headers for QML's WebEngineView

Kai Koehne Kai.Koehne at qt.io
Tue May 24 14:21:28 CEST 2016



> -----Original Message-----
> From: QtWebEngine [mailto:qtwebengine-bounces+kai.koehne=qt.io at qt-
> project.org] On Behalf Of Michael Bruning
> [...]
> if you would like to intercept the request directly in QML, then you're right,
> that's not possible at the moment. You could however create a C++ class that
> derives from QObject and, add a Q_INVOKABLE to it that takes some
> parameters that you pass to it from the qml side and creates a
> QWebEngineUrlRequestInterceptor that can be installed on the
> QQuickWebEngineProfile. Then you could register your class as a QML type
> and access it from within your QML code. It's not a very simple / straight
> forward solution, but it may work.

We consciously decided _not_ to support filtering inside QML, because this 
would require syncing between the IO thread and the GUI thread (where QML
runs).

Anyhow, setting it up in C++ is really easy. QQuickWebEngineProfile is a
public C++ class, so you can just create  an instance e.g. in main.cpp, 
set up the interceptor, and expose the profile object to Qt Quick, where you can 
set it as  active profile on your WebEngineView. 

http://doc.qt.io/qt-5/qquickwebengineprofile.html


Regards

Kai 



More information about the QtWebEngine mailing list