开发者

Run Linux commands from Qt4

开发者 https://www.devze.com 2022-12-18 10:25 出处:网络
How can I run command-line开发者_StackOverflow社区 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

How can I run command-line开发者_StackOverflow社区 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.


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();


Use QProcess.


What about using popen?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号