Important: Please read the Qt Code of Conduct -

QtWebEngine & HTML5 Application Cache

  • Dear Qt community,

    We started with QT a few weeks ago to create an application that's mainly based on a webview. At first I developed it with the webview / webkit and QML until I discoverd the much better engine QtWebEngine. The last days we are trying to find a way to get localStorage working with this one, without success.

    Everything works (video plays, html page loads) but when I disable my internet connection and refresh, I get the default Chromium error (no internet connection). The same code with WebKit is working perfectly, also I'm missing the option to set the setOfflineWebApplicationCachePath, wich was very handy with QtWebView.

    I'm wondering if anyone has experienced the same problem.

    Thank you,

    #include <QApplication>
    #include <QMainWindow>
    #include <QDir>
    #include <QString>
    #include <QStandardPaths>
    #include <QWebEngineView>
    #include <QWebEngineSettings>

    int main(int argc, char *argv[])
    QApplication app(argc, argv);

    QWebEngineView *webview = new QWebEngineView();
    QWebEngineSettings *defaultSettings = webview->settings();
    defaultSettings->setAttribute(QWebEngineSettings::LocalStorageEnabled, true);
    //defaultSettings->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
    QMainWindow *window = new QMainWindow();
    return app.exec();


  • Hi,

    Now you can use the following line for a QWebEngineView object :

    webview ->page()->profile()->setCachePath("C:/Users/yourUserName/AppCacheFolder");

    See you.

Log in to reply