views:

74

answers:

3

Hello,

In my Qt GUI application, I am calling the command prompt through:

system("lots.exe & of.exe && commands.exe");

It opens up the command prompt (like I want it to), but freezes the Qt GUI application until I close the command prompt. Is there someway to prevent this? I saw that there is a QProcess class, but can't get it to bring up the command prompt.

Any help would be greatly appreciated!

+1  A: 

You just need to put that system call in a separate thread.

Piotr Kalinowski
No need to do that when QProcess is available. Also there would be no good way to interrupt the thread while it was blocked in system(), which could cause problems if the underlying .exe's don't exit for a long time (or ever)
Jeremy Friesner
Which is a general problem with system(), I agree :)
Piotr Kalinowski
+5  A: 

QProcess is really the answer. If you want to use something like system() you'll have to either put the call in another thread or use popen or something simmilar for your platforms.

QProcess does have the setReadChannel which you could use to display your own console window to show the output.

Gianni
+1  A: 

If you do not need any of the output, the easiest way would be to use QProcess::startDetached().

http://doc.qt.nokia.com/4.6/qprocess.html#startDetached

If you do need the output, QtConcurrent::run with a futurewatcher containing the output would be less overhead/work than deriving QThread.

Chris