Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run Linux commands from Qt4

How can I run command-line programs under Linux from Qt4? And of course I want to obtain the output in some way I can use. I'd use it for an ls | grep, but it's good to know for any future issues.

like image 550
StJimmy Avatar asked Jan 27 '10 15:01

StJimmy


1 Answers

QProcess p;
p.start( /* whatever your command is, see the doc for param types */ );
p.waitForFinished(-1);

QString p_stdout = p.readAllStandardOutput();
QString p_stderr = p.readAllStandardError();
like image 130
Fred Avatar answered Oct 23 '22 17:10

Fred