Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. LocalStorage
QtWS25 Last Chance

LocalStorage

Scheduled Pinned Locked Moved QML and Qt Quick
8 Posts 3 Posters 2.6k Views
  • 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.
  • D Offline
    D Offline
    dstudentx
    wrote on last edited by
    #1

    Where is the localStorage database located? I can't find it anywhere

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Depends on the platform. This should return you the path:
      @
      QStandardPaths::standardLocations(QStandardPaths::DataLocation);
      // or in Qt4:
      QDesktopServices::storageLocation(QDesktopServices::DataLocation);
      @

      (Z(:^

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dstudentx
        wrote on last edited by
        #3

        Sorry I mean on my local system.

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          Yes, I do mean the same. Run this code and you will get the path to your DB (or somewhere close).

          (Z(:^

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SlimIT
            wrote on last edited by
            #5

            You can specify the location of your database using this command :

            For exemple to specify the current directory "./" you can use this command :

            @viewer.engine()->setOfflineStoragePath(QString("./"));@

            The name of the database is the md5 hash of the database name.

            For more details please visit this link :

            https://bugreports.qt-project.org/browse/QTBUG-16227

            1 Reply Last reply
            0
            • D Offline
              D Offline
              dstudentx
              wrote on last edited by
              #6

              Thanks for the help.
              I tried
              @
              viewer.engine()->setOfflineStoragePath(QString("./"));
              @

              but I'm not using c++
              Can't I just have the offlinedatabase in my project folder like

              desktop\project1\database_1

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SlimIT
                wrote on last edited by
                #7

                If you use c++ you will only have a main.cpp like this :

                @#include <QApplication>

                #include "qtquick2applicationviewer.h"

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

                QtQuick2ApplicationViewer viewer;
                viewer.engine()->setOfflineStoragePath(QString("./"));
                viewer.setSource(QUrl("main.qml"));
                viewer.showFullScreen();
                
                return app.exec&#40;&#41;;
                

                }
                @

                So if you can use C++ i think it's the best idea.

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  dstudentx
                  wrote on last edited by
                  #8

                  Sorry I can't use C++ for this project.

                  on my mac. the localstorage db is located in a hidden folder.
                  @
                  /Library
                  /Application Support
                  /Qt Project
                  /QTQmlViewer
                  /QML
                  /OfflineStorage
                  /Databases
                  @
                  This seems mental to me.

                  Why can't I just have it in my project folder like
                  @
                  /Desktop
                  /qml_projects
                  /test_project
                  @

                  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