When you create a QSqlDatabase with SQLite as the backend, you have two options:
- Give an absolute path as db name
- Give a relative path: in this case the database will be stored in the directory of your binary file.
So, you should know the absolute path of your dB in your case.
change
In the event that you initially know where the database should be located, you can either copy it (which is never reasonable), or you can create a configuration and load it using QSettings. For instance:
QSettings settings; QString dbPath = settings.readValue("DBPath", QString()).toString();
Look further here
source share