PDA

View Full Version : QWebEngineView LocalStorage



brixel
27th April 2016, 19:38
Greetings,

My application uses QWebEngineView and we utilize local storage. While testing I need the ability to remove the file being used for storage. I can't find in the documentation where the local storage is kept. I'd also like to be able to set the path, which looks like was achievable with web kit but I don't see the same option for the web engine.

So A) Can anyone point me in the direction of where the local storage is kept? and B) Does anyone know if you can set the path to one of your choosing?

Thanks.

anda_skoa
27th April 2016, 19:59
My guess would be that it is using QStandardPaths, likely AppDataLocation or AppLocalDataLocation

Cheers,
_

brixel
27th April 2016, 21:49
Thanks anda_skoa. I looked that over but doesn't seem to be where the HTML5 local storage is kept. I looked in both location and several others listed in the documentation there but found nothing for my application.

Added after 32 minutes:

Ok, I found that it should be under the QWebEngineProfile > persistentStoragePath, but I'm not seeing how to pull this profile from my instance of QWebEngineView.

anda_skoa
28th April 2016, 11:29
Ok, I found that it should be under the QWebEngineProfile > persistentStoragePath, but I'm not seeing how to pull this profile from my instance of QWebEngineView.
QWenEngineView::page(), then QWebEnginePage::profile().

Cheers,
_

brixel
28th April 2016, 12:09
I have found that I can at least obtain the path using the defaultProfile from QWebEngineProfile, however when I try to set the path to something else the program keeps crashing on every run. No stack trace is provided, the application simply crashes with "The program has unexpectedly finished.".

Are you unable to change the local storage path for the default profile?


QWenEngineView::page(), then QWebEnginePage::profile().

Cheers,
_

Thanks - I gave that a try and the program is still faulting when I try to use setPersistentStoragePath. I can get the path and display it, but when I try and set it the program crashes.



webview->page()->profile()->setPersistentStoragePath(somepath); // Causes program to crash.