Sirs
I am having a problem with something that is so blindingly obvious I can't see it!
I want to connect a running external process to a progress dialogue that closes when the process finishes, or by pressing the cancel button on the dialogue stops the process.
Program so far:

Qt Code:
  1. void MP3collection::normalise()
  2. {
  3. if ( check4normalise() )
  4. {
  5. infoWarnError(INFORMATION, nice("Normalise"), nice(QString("%1 already normalised").
  6. arg(ui->lbl_selection->text())));
  7. return;
  8. }
  9. QString file, cmd;
  10. QProcess *proc = new QProcess(this);
  11. QProgressDialog *dlg = new QProgressDialog("Normalisation", "Cancel",0,0);
  12. dlg->setModal(Qt::WindowModal);
  13. file = QString("%1/%2.mp3").arg(currentDir, ui->lbl_selection->text());
  14. cmd = "lame";
  15. args.append("--scale");
  16. args.append("2");
  17. args.append(file);
  18. args.append(tmpFile);
  19. proc->start(cmd, args);
  20. connect(proc, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(procEnd(int)));
  21. // proc->waitForFinished(); /// Including this leaves blank previous dialogues.
  22. dlg->exec();
  23. connect(proc, SIGNAL(finished(int)), dlg, SLOT(close())); /// These don't seem to work
  24. connect(dlg, SIGNAL(finished(int)), proc, SLOT(kill())); /// ditto
  25. }
  26.  
  27. void MP3collection::procEnd(int i)
  28. {
  29. //It would be nice to close the dialogue here but it doesn't know about [I]dlg[/I] of course.
  30. qDebug()<<i;
  31. // close();
  32. }
To copy to clipboard, switch view to plain text mode 

The program runs and the process works as expected. I cannot stop the process and the dialogue remains after the process has finished requiring the cancel button.

Any advice would be much appreciated.
Thanks in advance
Graham