Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to enable LocalStorage in Qt 5.3
Forum Updated to NodeBB v4.3 + New Features

How to enable LocalStorage in Qt 5.3

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JohnnyFee
    wrote on last edited by
    #1

    I tried the method:

    @
    QWebSettings* settings = QWebSettings::globalSettings();
    settings->setAttribute(QWebSettings::LocalStorageEnabled, true);
    auto path = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
    settings->setOfflineStoragePath(path);

    @

    window.localStorage is not undefined, but when I insert a item into the localStorage:

    @localStorage.setItem("b","isaac");
    alert(localStorage["b"]);@

    The error is happened, and the error messages in the webkit inspector console are:

    bq. QuotaExceededError: DOM Exception 22: An attempt was made to add something to storage that exceeded the quota.

    1 Reply Last reply
    0
    • J Offline
      J Offline
      JohnnyFee
      wrote on last edited by
      #2

      I forgot I've enable a very important swithcer:

      @settings->setAttribute(QWebSettings::PrivateBrowsingEnabled,true);@
      This will set the browser to private mode and prevent you to insert value to localStorage. But the official api doc doesn't mention it.

      You just set disable the switcher can solve the problem:

      @settings->setAttribute(QWebSettings::PrivateBrowsingEnabled,false);@

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved