In a project I use Qthreads. Some actions are triggered by clicking a button, and are executed from a thread (to lete interfac be responsive during actions executions)

I have attached a little example to figure out my doubt
ThreadTest.zip

I have this dialog:
ThreadExample.jpg

When the button is clicked is called the following slot:
Qt Code:
  1. void Dialog::slotBtn(void)
  2. {
  3. // MyThread *myt; // declared in the class
  4. myt = new MyThread;
  5.  
  6. myt->start();
  7. }
To copy to clipboard, switch view to plain text mode 

where MyThread is:
Qt Code:
  1. #include <QThread>
  2.  
  3. class MyThread : public QThread
  4. {
  5. public:
  6. MyThread();
  7.  
  8. void run(void);
  9. };
  10.  
  11. MyThread::MyThread()
  12. {
  13. }
  14.  
  15.  
  16. void MyThread::run(void)
  17. {
  18. // some stuff that can takes some time
  19. sleep(1);
  20.  
  21. qWarning("hallo world from MyThread");
  22. //end of thread
  23. }
To copy to clipboard, switch view to plain text mode 

I wonder when to delete myt.

For example, when a thread finish a signal QThread::finished() is emitted. I can connect to a slot, but I wonder if it is safe to delete it inside that slot.

thanks