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. Can't make Qt look in project directory for db.
Forum Updated to NodeBB v4.3 + New Features

Can't make Qt look in project directory for db.

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 954 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.
  • O Offline
    O Offline
    ogrishmania
    wrote on last edited by
    #1

    So I have a project which reads info from a sqlite3 DB. If I point the full path (C:\Users\bla\Desktop\myPrjFolder\myDB.3db) it works but if I point the absolute path (I think is called) \myDB.3db it doesn't. I also tried via a resource file :prefix/myDB.3db still doesn't works. I need to do this so the project can be portable.

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vezprog
      wrote on last edited by
      #2

      If your looking to make it look in the project directory (aka, your build directory, or where your executable lies), then there at Qt calls for that in the QApplication class.

      try QApplication::applicationDirPath()

      So if the folder is your build directory, do:
      @
      QString dbName = "mbDB.3db";
      QString dbPath = QApplication::applicationDirPath() + "\" + dbName;
      @

      1 Reply Last reply
      0
      • O Offline
        O Offline
        ogrishmania
        wrote on last edited by
        #3

        Thank you for your response.

        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