QProcess problem (Main program hangs)
Hello. I am trying to call the eog command (it's an image viewing software) from my Qt application. This is the code.
Code:
void MainWindow::doRawViewer(){
this,
tr("Required Save"),
tr("Save the image first in order to view this image under the system's default image viewer"));
if (fileName.isNull())
return;
#if defined(Q_OS_WIN32)
viewImageProcess.start(fileName);
#elif defined(Q_OS_LINUX)
viewImageProcess.
execute(QString("eog ") + fileName
);
// viewImageProcess.start(QString("eog ") + fileName);
#endif
}
eog runs properly and it correctly displays the image, the problem is when I close eog, my Qt application hangs. Is this a memory problem or I'm just not using QProcess::execute() and QProcess::start() correctly?
Also, I do not know how to use task manager in ubuntu. can anyone point me to how I can manage the Qt Application when it hangs? It does not force quit at all.
Re: QProcess problem (Main program hangs)
Quote:
Originally Posted by
sincnarf
Is this a memory problem or I'm just not using QProcess::execute() and QProcess::start() correctly?
QProcess::execute() is a static method, so you don't need a QProcess instance to invoke it, and even if you do have one, it won't affect it.
Do you wait for that eog application to close somewhere in your program?
Quote:
Originally Posted by
sincnarf
Also, I do not know how to use task manager in ubuntu. can anyone point me to how I can manage the Qt Application when it hangs?
man ps
man kill
Re: QProcess problem (Main program hangs)
QProcess::execute():
Quote:
Starts the program program with the arguments arguments in a new process, waits for it to finish, and then returns the exit code of the process.
Re: QProcess problem (Main program hangs)
Quote:
Originally Posted by
jpn
Starts the program program with the arguments arguments in a new process, waits for it to finish, and then returns the exit code of the process.
Yes, but this doesn't explain the hanging. I wonder whether the application, doesn't look like this:
Code:
...
...
p.waitForFinished( ... );
Re: QProcess problem (Main program hangs)
I didn't use waitForFinished because this means I have to close eog first before I can get back to my mainwindow. What I was trying to do was to both simultaneously run my mainwindow and the process eog.
Does this mean I can't run my mainwindow along with the QProcess that calls eog?
Re: QProcess problem (Main program hangs)
You can, you just can't use the static method approach. You need to create a regular QProcess object (on heap), call start() on it and voila. You should be able to continue using your application while the viewer executes. If your application still hangs, it means the process has nothing to do with it - try commenting out those lines related to QProcess and see if the application hangs or not.