finally migrated the pthread function into the QCoreApplication eventloop, still very hacky!