0

My Qt Project uses .csv(not my choice) files to save and load data from ,as i am looking to deploy the app , how do i add these files into the release version and what changes to my code should i do ?

right now i am using QFile and giving it the full path to each file like so :

QFile Fich1("C:/Users/ahmed/Desktop/MyWork/QtProject/Bibliotheque/Arrays.csv");

1 Answers1

0

If you're looking to ship CSV files as part of your application, one good way to do it is to use Qt's resource-file system; then they will be compiled into your app so there's no chance of them getting lost/modified/moved.

OTOH if you want to ship CSV files with your app but as separate files (e.g. so that the user can see and load them using a file dialog), then you can package them together with the executable, and then use QCoreApplication::applicationDirPath() as the default directory for the QFileDialog to present to the user.

Jeremy Friesner
  • 70,199
  • 15
  • 131
  • 234
  • I tried adding them as resource-files but the data saved in an execution is lost when executing again. – Ahmed Hamila Nov 25 '21 at 23:31
  • 1
    Right, application installs are generally considered read-only. If you need to save data you should save it to somewhere writeable, such as to the user’s home folder. The Qt QstandardPaths API can help suggest a suitable place to save your data: https://doc.qt.io/qt-5/qstandardpaths.html#details – Jeremy Friesner Nov 25 '21 at 23:44