Hello,
I wrote a single piece of code that need to be run in the thread, but I have problem quit'ing the QThread itself.

Qt Code:
  1. void MainWindow::on_tb_prev_Refresh_clicked()
  2. {
  3. vFilePrev = new videoFilePreview();
  4. th = new QThread();
  5. vFilePrev->moveToThread( th );
  6.  
  7. connect( th, SIGNAL(started()), this, SLOT(threadStarted()));
  8. connect( th, SIGNAL(finished()), this, SLOT(threadFinished()));
  9. connect(vFilePrev, SIGNAL(finishedJob()), this, SLOT( vidPreviewFinished()));
  10. connect(vFilePrev, SIGNAL(finishedJob()), th, SLOT( quit()));
  11.  
  12. th->start();
  13.  
  14. qDebug() << "gui thread: " << this->thread();
  15. }
  16.  
  17. void MainWindow::threadStarted()
  18. {
  19. qDebug() << "Start th";
  20. vFilePrev->makePreview( tmp );
  21. }
  22.  
  23. void MainWindow::vidPreviewFinished()
  24. {
  25. qDebug() << "vidPreviewFinished in thread: " << this->thread();
  26.  
  27. disconnect(vFilePrev, SIGNAL(finishedJob()), this, SLOT( vidPreviewFinished()));
  28. delete vFilePrev;
  29. }
  30.  
  31. void MainWindow::threadFinished()
  32. {
  33. disconnect( th, SIGNAL(started()), this, SLOT(threadStarted()));
  34. disconnect( th, SIGNAL(finished()), this, SLOT(threadFinished()));
  35. disconnect( vFilePrev, SIGNAL(finishedJob()), th, SLOT( quit()));
  36.  
  37. delete th;
  38.  
  39. qDebug() << "delete th";
  40. }
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. #include <QObject>
  2. #include <QDebug>
  3. #include <QStringList>
  4.  
  5. class videoFilePreview : public QObject
  6. {
  7. Q_OBJECT
  8. public:
  9. explicit videoFilePreview(QObject *parent = 0);
  10. void makePreview( QStringList );
  11.  
  12. private:
  13.  
  14.  
  15. signals:
  16. void finishedJob();
  17.  
  18. public slots:
  19.  
  20. };
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. videoFilePreview::videoFilePreview(QObject *parent) :
  2. QObject(parent)
  3. {
  4. }
  5.  
  6. void videoFilePreview::makePreview( QStringList fileList )
  7. {
  8. qDebug() << "in the thread: " << this->thread();
  9.  
  10. emit finishedJob();
  11. }
To copy to clipboard, switch view to plain text mode 
And the problem with this is that connect( th, SIGNAL(finished()), this, SLOT(threadFinished())); never invoke SLOT(threadFinished());

Thanks for any suggestions.
Regards