Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable LocalStorage in QML WebView for Android?

I am building webview-based Qt app for Android, which talks to Emberjs. However, it seems that QML WebView does not support LocalStorage (but supports SessionStorage).

Are there any way to enable it? Or may you help me find a line in the documentation which states that LocalStorage is not supported in a QML WebView, since same code works for iOS?

(I know that Qt does not support WebEngineView & WebKit for mobile.)

like image 444
lesyk Avatar asked Nov 09 '22 00:11

lesyk


1 Answers

As stated way:

 A WebView renders web content within a QML application.

The WebView is a component meant to download contents from the web and from within you cannot access objects that belong to the surrounding environment (that is, your QML application).
Anyway, you can intercept requests by means of the onNavigationRequested signal (see here for further details), thus maybe you can imagine a webapp that tries to query a service by means of a REST API and an app that intercepts those requests and interact with the local storage.

To be honest, by looking at the documentation for Qt 4.8, the WebView offered a way to inject objects from the QML environment, but it seems to be no longer available on Qt 5.5.
Anyway, I strongly suggest to have a look at these examples, available on the Qt website: maybe they can be helpful.

like image 74
skypjack Avatar answered Nov 14 '22 22:11

skypjack