i created a program which has a button "scan" (scan DAB frequencies) and after all is finished list output in a QWidgetList. This was working without problems.

Now to inform the user about the progress of the scan I added a progressbar, which also works. To make this work I added a QThread for the scan function, but now if 100% is reached, the list is not updated, it stays empty. It gets filled when I hit "scan" again.

Already tried to stop the thread with a boolean.

Qt Code:
  1. void Dialog::on_btnDabScanFreq_clicked()
  2. {
  4. connect(&mScan,&Scan::progress_scan_dab,this,&Dialog::prog_bar_dab_valueChanged);
  6. QFuture<void> scan_dab = QtConcurrent::run(&this->mScan,&Scan::dab_scan_wrapped);
  8. ui->list_dab->clear();
  10. for(int i = 0; i < mScan.dab_vec_vec.size(); i++){
  12. ui->list_dab->addItem(mScan.dab_vec_vec[i][0]);
  13. }
  14. }
To copy to clipboard, switch view to plain text mode 

To make the thread work i had to wrap the called function:

Qt Code:
  1. void Scan::dab_scan_wrapped(){
  3. forever{
  5. if(mStop_dab_scan) break;
  7. int devfd = -1;
  8. int console = -1;
  9. int running = -1;
  11. Scan::media_scan_dabfrequencies("/dev/dab0",devfd,console,running);
  12. }
  13. }
To copy to clipboard, switch view to plain text mode 

The boolean switch is triggered, when 100% is reached:

Qt Code:
  1. if(prog_bar_dab == 100){
  2. mStop_dab_scan = true;
  3. }
To copy to clipboard, switch view to plain text mode 

Which function needs to be stopped to stop the thread? The wrapper function which is called by button scan, or the real scan function?

The "real" scan function writes it's result to dab_vec_vec.