It's a not very good solution cause when you start doWork you can't stop it till it finished.
You can try to modify your example by starting your work with singleshot timer after thread is started.
@QTimer::singleShot(0, w, SLOT(doWork());@
and remove
@connect(&t, SIGNAL(started()), &w, SLOT(doWork()), Qt::DirectConnection);@
Also, as I understand, you should use auto or queued connection here, cause worker and thread are in different threads.
@connect(&w, SIGNAL(finished()), &t, SLOT(quit()));@