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. adding sqlite file into qrc file system
Forum Updated to NodeBB v4.3 + New Features

adding sqlite file into qrc file system

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 816 Views 3 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.
  • D Offline
    D Offline
    divaindie
    wrote on last edited by
    #1

    is it possible to add database file into qrc file system? I assume that we can add only binary files into qrc file,so even if we add a database file we cannot access it using "qrc://database_file " address (i guess qsqldatabase.setDatabaseName("qrc://database_file") will fail).am i right on this? .please suggest me a way through which i can add a database file into qrc file system to access it during my application execution.

    Pablo J. RoginaP 1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      It cannot use a db in a qrc directly.
      You need to copy the db file to writable location when app starts.
      and then open it from the new location.

      1 Reply Last reply
      4
      • D divaindie

        is it possible to add database file into qrc file system? I assume that we can add only binary files into qrc file,so even if we add a database file we cannot access it using "qrc://database_file " address (i guess qsqldatabase.setDatabaseName("qrc://database_file") will fail).am i right on this? .please suggest me a way through which i can add a database file into qrc file system to access it during my application execution.

        Pablo J. RoginaP Offline
        Pablo J. RoginaP Offline
        Pablo J. Rogina
        wrote on last edited by
        #3

        @divaindie in addition to @mrjj response, please keep in mind that deploying a DB from Qt resource system (qrc:) should be used for read-only DBs.
        If you pack the DB into qrc:, then you copy from qrc: into OS and start using it, and the user updates DB content two things may happen:

        1. you won't be able to get that DB status into qrc: back again (doing so it will imply changing the executable of your Qt app...)
        2. Be careful in next app startup, since extracting the DB again will overwrite existing file which was previously updated...

        Upvote the answer(s) that helped you solve the issue
        Use "Topic Tools" button to mark your post as Solved
        Add screenshots via postimage.org
        Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

        D 1 Reply Last reply
        3
        • Pablo J. RoginaP Pablo J. Rogina

          @divaindie in addition to @mrjj response, please keep in mind that deploying a DB from Qt resource system (qrc:) should be used for read-only DBs.
          If you pack the DB into qrc:, then you copy from qrc: into OS and start using it, and the user updates DB content two things may happen:

          1. you won't be able to get that DB status into qrc: back again (doing so it will imply changing the executable of your Qt app...)
          2. Be careful in next app startup, since extracting the DB again will overwrite existing file which was previously updated...
          D Offline
          D Offline
          divaindie
          wrote on last edited by divaindie
          #4

          @Pablo-J.-Rogina how can i copy the db file into writable location for ANDROID and LINUX? iam new to QT.so can you please show me a detailed step of doing this ?

          1 Reply Last reply
          -1
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Hi,

            That question has already been asked many times. Please search the forum a bit.

            QStandardPaths::writableLocation to the rescue.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            2

            • Login

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