I am using a SQLite database in a Qt app and it works fine building on both windows and linux. Running it from Qt Creator works fine on both machines but if I execute the binary directly it doesn't find the database on linux but does on windows.

Qt Code:
  1. QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
  2. db.setDatabaseName("db/database.sqlite");
To copy to clipboard, switch view to plain text mode 

Also, when I build on windows the binary is located at <projectdir>/debug or <projectdir>/release depending on which build config I use but on Linux it's always located at <projectdir>.

Why is it like that? Shouldn't Qt Creator handle paths relative to the project in the same manner on both platforms?