How to set cookies for a WebView in qml

901 views Asked by At

Currently I am trying to do this by accessing the “QWebView” object. Following is the code that I use:

QObject* window = getQmlWindow("appWindow"); // returns the top-level qml ApplicationWindow
QObject* webView = window->findChild<QObject*>("QWebView"); // WebView has an objectName = "QWebView"
QWebView* qWebView = static_cast<QWebView *>(webView); // Cast QObject to QWebView

qWebView->page()->networkAccessManager()->setCookieJar(cookies); // cookies is of type QNetworkCookieJar* 

it gives a segmentation fault error while accessing networkAccessManager().

Am i doing it in the right way? Is there any other ways to set cookies for Qml WebView. I am using QtQuick 5.1 and QtWebKit 3.0.

Note:

  1. This is a cross posting of the original question

  2. There might be some similarity with the question,

    but it doesn't solve my question.

0

There are 0 answers