Connecting qprocess and qprogressdialogue
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:
Code:
void MP3collection::normalise()
{
if ( check4normalise() )
{
infoWarnError
(INFORMATION, nice
("Normalise"), nice
(QString("%1 already normalised").
arg(ui->lbl_selection->text())));
return;
}
dlg->setModal(Qt::WindowModal);
file = QString("%1/%2.mp3").
arg(currentDir, ui
->lbl_selection
->text
());
cmd = "lame";
args.append("--scale");
args.append("2");
args.append(file);
args.append(tmpFile);
proc->start(cmd, args);
connect(proc,
SIGNAL(finished
(int,
QProcess::ExitStatus)),
this,
SLOT(procEnd
(int)));
// proc->waitForFinished(); /// Including this leaves blank previous dialogues.
dlg->exec();
connect(proc, SIGNAL(finished(int)), dlg, SLOT(close())); /// These don't seem to work
connect(dlg, SIGNAL(finished(int)), proc, SLOT(kill())); /// ditto
}
void MP3collection::procEnd(int i)
{
//It would be nice to close the dialogue here but it doesn't know about [I]dlg[/I] of course.
qDebug()<<i;
// close();
}
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
Re: Connecting qprocess and qprogressdialogue
Quote:
Originally Posted by
GrahamB
Code:
dlg->exec();
connect(proc, SIGNAL(finished(int)), dlg, SLOT(close())); /// These don't seem to work
connect(dlg, SIGNAL(finished(int)), proc, SLOT(kill())); /// ditto
1) Why connect after the dialog has finished?
You want these connections to be available while the dialog is active.
2) There is no such signal in QProcess
3) There is no such signal in QProgressDialog
Cheers,
_