I'm relatively new to Qt but I have just finished my first program for a project. I have a .sqlite file that I open by doing this:
db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("/Users/.../.../Code/Database/AIOCS.sqlite"); //shortened for clarity
I need to send this program to my professor, but obviously if the program tries to compile, the database won't open because the path is wrong. Im trying to run the application without having to specify the file path in my the code. Is there a way to place the file in a local directory where I only have to specify the file name. Something like:
db.setDatabaseName("AIOCS.sqlite");
For example, if I run my program on a mac, I will have to use:
db.setDatabaseName("/Users/.../.../Code/Database/AIOCS.sqlite"); //shortened for clarity
but, on pc it will be
db.setDatabaseName("C:\\User\\...\\Code\\Database\\AIOCS.sqlite"); //shortened for clarity
Is there a way to just use the file name, that way the program can run on any machine without changing code.
"db.setDatabaseName("../../Code/Database/AIOCS.sqlite");"