Nominate our 2022 Qt Champions!

QML WebView 3.0 don't use the provided QQmlNetworkAccessManagerFactory

  • I have subclassed QQmlNetworkAccessManagerFactory because I want that the QML WebView item sends a custom user agent string.
    But it seems the WebView doesn't use the custom QQmlNetworkAccessManagerFactory.

    Is this a normal behavior? Can I change the user agent string on some other way?

    This is my code:
    class NetworkAccessManagerFactory : public QQmlNetworkAccessManagerFactory
    QNetworkAccessManager* create(QObject* parent)
    qDebug() << "Create function called.";
    return new QUserAgentNetworkAccessManager("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0b8) Gecko/20100101 Firefox/4.0b8", parent);

    int main(int argc, char *argv[])
    QGuiApplication a(argc, argv);
    QQuickView viewer;

    NetworkAccessManagerFactory factory;
    //qDebug() << viewer.engine()->networkAccessManager();
    return a.exec&#40;&#41;;


    The create() function is never called. If I comment in the qDebug() line, the create function is called once. Does webkit not use the network manager from the qml engine?

    The main.qml is just a simle webview:
    import QtQuick 2.0
    import QtWebKit 3.0

    WebView {
    width: 600; height: 600

    url: ""


Log in to reply