0

I'm facing the following problem:

I wrote a simple application to track working hours. Therefor I create a *.db file programmatically. Launching the application from Qt Creator (debug or release) works perfectly fine. I used the macdeployqt tool to get a *.dmg file. When starting the application now the method (see below) cannot open, respectively create the *.db file and I run out of ideas why. In addition to this, the application should output some *.csv files. This also fails. One more information, running the application as administrator using the sudo command on terminal...well it works and the *.db file and *.csv files get created. So I am quite sure it must deal with file permissions but I have no idea how to change this except for changing it in the information context menu but this didn't help at all.

Below the method for the *.db file which always returns false when not launching the app from Qt Creator:

QFile file(Globals::Environment::WORKING_DIRECTORY + "/" + "Records.db");

if(file.open(QIODevice::ReadWrite))
    return true;
else
{
    QMessageBox msg;
    msg.setWindowTitle("Error");
    msg.setText("Failed to create database file!");
    msg.exec();
}
return false;

I am on MacOS 10.11.3. Qt 5.5.1 (Clang 6.1 (Apple), 64 bit)

If more information is needed, I will provide it of course.

Thanks a lot for every help in advance.

marcus
  • 138
  • 1
  • 1
  • 8
  • Are you packing your application into an app bundle? – MrEricSir Mar 03 '16 at 19:14
  • Yes, I compile it in release mode and after this I execute: macdeployqt app name.app -dmg in the folder of the app bundle. Any ideas? – marcus Mar 03 '16 at 19:18
  • 1
    My guess is you're trying to save your database file inside the app bundle itself. You should look into saving it somewhere in the user's home folder instead, since you'll have permission to write there. – MrEricSir Mar 03 '16 at 19:30
  • Thank you very much. Seems like this has been the problem. Now...writing to the homePath() made it work :-) – marcus Mar 03 '16 at 19:58

0 Answers0