Important: Please read the Qt Code of Conduct -

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

  • 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.

  • 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;

  • Thank you for your response.

Log in to reply