sa5webber
1st June 2012, 21:53
I'm new to QT so I'm sure I'm either misunderstanding something or just doing something wrong.
The problem is that when I run the code below, it opens up the application and also immediately
calls the finished() function even though the application is still running. I wouldn't expect it to
emit the finished signal until after the application has exited?
What am I missing?
Here is my test code.
*****************************************
mainwindow.h
==========
private slots:
void procEditFinished(int exitCode, QProcess::ExitStatus exitStatus);
private:
QProcess *procEdit;
mainwindow.cpp
============
void MainWindow::on_btnEdit_clicked()
{
QString app = "/usr/bin/gedit";
QStringList arg;
arg << "file.txt";
procEdit = new QProcess(this);
connect(procEdit, SIGNAL(finished(int, QProcess::ExitStatus)),
this, SLOT(procEditFinished(int, QProcess::ExitStatus)));
procEdit->start(app, arg);
}
void MainWindow::procEditFinished(int exitCode, QProcess::ExitStatus exitStatus)
{
qDebug("exitCode= %d, exitStatus= %d", exitCode, exitStatus);
procEdit->deleteLater();
}
The problem is that when I run the code below, it opens up the application and also immediately
calls the finished() function even though the application is still running. I wouldn't expect it to
emit the finished signal until after the application has exited?
What am I missing?
Here is my test code.
*****************************************
mainwindow.h
==========
private slots:
void procEditFinished(int exitCode, QProcess::ExitStatus exitStatus);
private:
QProcess *procEdit;
mainwindow.cpp
============
void MainWindow::on_btnEdit_clicked()
{
QString app = "/usr/bin/gedit";
QStringList arg;
arg << "file.txt";
procEdit = new QProcess(this);
connect(procEdit, SIGNAL(finished(int, QProcess::ExitStatus)),
this, SLOT(procEditFinished(int, QProcess::ExitStatus)));
procEdit->start(app, arg);
}
void MainWindow::procEditFinished(int exitCode, QProcess::ExitStatus exitStatus)
{
qDebug("exitCode= %d, exitStatus= %d", exitCode, exitStatus);
procEdit->deleteLater();
}