This my code:
Qt Code:
  1. class MyQTForm : public QMainWindow {
  2. private:
  3. Q_OBJECT
  4. QProcess *process;
  5. //...
To copy to clipboard, switch view to plain text mode 
Now the part I want to process:
Qt Code:
  1. void MyQTForm::cb_process_dir(const QString& _in, const QString& _out) {
  2. QDir in_dir (_in);
  3. QStringList filters;
  4. filters << "*.mp3" << "*.flv" << "*.mp4";
  5. QStringList dir_list = in_dir.entryList (filters);
  6. int index = 0;
  7. int total = dir_list.size();
  8. for (; index < total; index++) {
  9. QString file_in = _in + QString("/") + dir_list[index];
  10. QFileInfo fi(file_in);
  11. QString file_out = _out + QString("/") + fi.baseName() + QString(".mp3");
  12. cb_process (file_in, file_out); // a lot of files to process
  13. }
  14. }
  15.  
  16. void MyQTForm::cb_process (const QString& file_in, const QString& file_out) {
  17. QString cmd;
  18. QTextStream(&cmd) << "ffmpeg -i \"" << file_in << "\" -f mp3 -ab 128k \"" << file_out << "\"";
  19. process = new QProcess(this);
  20. process->setStandardOutputFile(tr("/dev/null"));
  21. connect(process, SIGNAL(started()),this, SLOT(onProcessStarted ()));
  22. connect(process, SIGNAL(finished(int, QProcess::ExitStatus)),this, SLOT(onProcessEnded ()));
  23. connect(process, SIGNAL(finished(int,QProcess::ExitStatus)), process, SLOT(deleteLater()) );
  24. process->start(cmd);
  25. }
  26.  
  27. void MyQTForm::onProcessStarted() {
  28. activo = true;
  29. menuBar()->setEnabled(!activo);
  30. statusBar()->showMessage(tr("Convirtiendo..."));
  31. }
  32.  
  33. void MyQTForm::onProcessEnded() {
  34. activo = false;
  35. menuBar()->setEnabled(!activo);
  36. if (check1->isChecked()) {
  37. //QFile::remove (_out_file_tmp);
  38. }
  39. statusBar()->showMessage(tr("Hecho"));
  40. }
To copy to clipboard, switch view to plain text mode 
This are the results:
1.- ffmpeg is launch as many times as many files are passed to cb_process, bad idea if we found a lot :\
2.- at some point I get: QProcess: Destroyed while process is still running.

My idea is that " process->start(cmd);" sould wait untill the current ffmpeg operation is done, so it can continue the loop...any help, please?