Couple of options

1) Store the data in a member variable of the class, of course with proper locking and handle the database query in the main thread once the function has finished

2) Return the data from the trainFHOG() function, retrieve from the future after completion and do the database interaction in the main thread

3) As ^NyAw^ suggested emitting the data from the trainFHOG() using a signal, then do the database interaction in the main thread

4) Create a new database connection inside the trainFHOG() function using QSqlDataBase::addDatabase() with different name than the one used on the main thread.
Also obviously calling removeDatabase() before returning.

Cheers,
_