You don't have to transfer pointers to the database (assuming you are using QSqlDatabase). You can always retrieve the connection by calling it by name. See docs of QSqlDatabase.