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. Qt Quick Local Storage Export / Import Database
Forum Updated to NodeBB v4.3 + New Features

Qt Quick Local Storage Export / Import Database

Scheduled Pinned Locked Moved QML and Qt Quick
6 Posts 2 Posters 2.5k 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.
  • C Offline
    C Offline
    charlesveasey
    wrote on last edited by
    #1

    Hello,

    I'm using QML local storage in my application. I'd like my user to be able to export and import the database file for backup and migration. Is this possible using the QML interface or do I need to rewrite my DB bindings in C++?

    Thanks,
    Charles

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      Can you explain what do you mean by import and export from your application point of view ?
      IMO, backup and migration must be done through c++

      157

      1 Reply Last reply
      0
      • C Offline
        C Offline
        charlesveasey
        wrote on last edited by
        #3

        Hi,

        QML Local Storage creates an SQLLite database file internally. Is there a way allow the user to copy that file and replace it. To export (save database file as), and to import (replace current database with saved file). I know the file operations will be done in C++. I'm wondering if I can continue to use QML Local Storage and allow import/export of the database file?

        Thanks,
        Charles

        1 Reply Last reply
        0
        • p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          There's no way to copy and replace file from QML. Do those from C++ side. You can use those "QFile::exists":http://qt-project.org/doc/qt-5/qfile.html#exists-2, QFile::copy and QFile::remove static functions.

          Yes sure you use QML local storage. After all it would be a db file physically present on the system. Do the file operations from c++ before your QML loads or as per your requirement.

          157

          1 Reply Last reply
          0
          • C Offline
            C Offline
            charlesveasey
            wrote on last edited by
            #5

            Thanks very much. This all makes sense.

            However, how do I get the filepath of the DB file? I'm targeting Win32 / OSX / Ubuntu desktops.

            1 Reply Last reply
            0
            • p3c0P Offline
              p3c0P Offline
              p3c0
              Moderators
              wrote on last edited by
              #6

              The file is actually created in a standard Data location of your system and that too inside the <your ApplicationName> folder.
              You can use "offlineStoragePath":http://qt-project.org/doc/qt-5/qqmlengine.html#offlineStoragePath-prop to get the path of DB.

              157

              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