About using threads for the database I suggest you to run the Qt loop in a thread using exec() and just create slots that perform the different queries, using queued connections. That way you don't need to use wait conditions, you can connect signals to slots in your thread and you can receive database notifications if the database driver supports them.