learn from http://stackoverflow.com/questions/26986685/qtextstream-doesnt-write-before-qthreadsleep