PDA

View Full Version : Problems executing system



gorka_sm
4th May 2011, 09:43
Hello , I am working with Qt in Linux and I would like to execute a comand and obtain the result of that comand and keep it in a String . I use the comand system but it returns 0 or 1 , but I am interested in obtaining the result of than comand.
For example
system("java -jar project.jar ")

I would like to obtain the result of executing "java -jar project.jar" and keep it in a QString, but I only obtain 0 or 1.
Thanks
Gorka

Zlatomir
4th May 2011, 10:37
You can use QProcess (http://doc.qt.nokia.com/latest/qprocess.html), that system not portable.

LE: correction: Linux has a system, sorry for my wrong intervention.
Anyway you can give QProcess a try - it has more functionality (see the documentation link).

cincirin
5th May 2011, 12:07
You can redirect stdout ( and stderr) to your file, then read the file content in QString