I have GUI in which on button click copy the content from one file to another file.While copying my GUI get hangs and it get release once the copying is done.
I tried to implement QtConcurrent function in my program but still GUI hangs for couple of second.
My code
Qt Code:
  1. connect(ui->button1,SIGNAL(clicked()),this,SLOT(select_C_file()));
  2. void MainWindow::select_C_file()
  3. {
  4. QDir directory("Documents");
  5. QString path = directory.filePath(" ");
  6. QString fileName = QFileDialog::getOpenFileName(this,tr("Open File"),path,tr("(*.lst)"));//open the file path which has to copy
  7.  
  8. //Thread implementation
  9. QFuture<void> future = QtConcurrent::run(this,&MainWindow::openCfile,QString(fileName));
  10. future.waitForFinished();
  11.  
  12. void MainWindow::openCfile(QString fileName)
  13. {
  14. //program to copy
  15. }
  16.  
  17. }
To copy to clipboard, switch view to plain text mode 
My program is working perfectly but still my GUI is getting hang.
Please let me how can I use Qthread instead of QtConcurrent.Where my Qthread should start on the button click and should end once the copying is done or it should be in threadloop.