Gui app on Mac doesn't see my SQLite database, when launched by double-click on .app itself
-
wrote on 25 Nov 2017, 23:00 last edited by
Sorry for newbie questions, I'm not so familiar with deployment, but I don't know where to start.
So, when Qt compiles and runs my app, everything works fine, but when I try to double click on app file/package from Debug (or Release) folder - app doesn't see database (won't write or show it's content). The difference is: Qt is launching not app itself, but executable from app package (sqltablemodel3.app/Contents/MacOS/sqltablemodel3).
I tried to investigate, but found only some thread from 2010 with broken doc link. Also, I see official info for "The Mac Deployment Tool", but in Qt in Build menu I see some separate "Run without deployment" option. Does it mean, that deployment automatically runs by default?
Am I missing some step? -
Hi
http://doc.qt.io/qt-5/osx-deployment.htmlThe deployment tool is a command line tool that you run your self.
( at least on windows)I assume it will be the same on macOS
-
wrote on 27 Nov 2017, 13:28 last edited by Maxxii
I'm just not sure I need deployment at this point, because I don't want to distribute my app. I just wanted it to launch by clicking on .app file.
I think I figured it out by searching again at this forum and reading through some more (not-Mac related) topics.
So, I fixed this by adding QCoreApplication::applicationDirPath() to the path of my database, so now it looks like this:db.setDatabaseName(QCoreApplication::applicationDirPath()+"db.sqlite");
-
I'm just not sure I need deployment at this point, because I don't want to distribute my app. I just wanted it to launch by clicking on .app file.
I think I figured it out by searching again at this forum and reading through some more (not-Mac related) topics.
So, I fixed this by adding QCoreApplication::applicationDirPath() to the path of my database, so now it looks like this:db.setDatabaseName(QCoreApplication::applicationDirPath()+"db.sqlite");
wrote on 27 Nov 2017, 13:50 last edited by@Maxxii said in Gui app on Mac doesn't see my SQLite database, when launched by double-click on .app itself:
db.sqlite
be carefull because QCoreApplication::applicationDirPath() return the location inside the app bundle, if you place your database at the same level that yourapplication.app it will doesnt work.
-
@Maxxii said in Gui app on Mac doesn't see my SQLite database, when launched by double-click on .app itself:
db.sqlite
be carefull because QCoreApplication::applicationDirPath() return the location inside the app bundle, if you place your database at the same level that yourapplication.app it will doesnt work.
-
Hi,
To add to @cfdev good point, you should use QStandardPaths to retrieve a proper folder to store your database.
1/6