Quantcast
Channel: Qt DevNet forums: Qt WebKit
Viewing all articles
Browse latest Browse all 542

QML WebView 3.0 don't use the provided QQmlNetworkAccessManagerFactory

$
0
0
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 { public:     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;     viewer.engine()->setNetworkAccessManagerFactory(&factory);       //qDebug() << viewer.engine()->networkAccessManager();       viewer.setResizeMode(QQuickView::SizeViewToRootObject);     viewer.setSource(QUrl("qrc:/main.qml"));     viewer.show();       return a.exec(); } 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: "http://www.google.de" }

Viewing all articles
Browse latest Browse all 542

Trending Articles