Run Linux commands from Qt4

2020-02-10 05:21发布

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.

3条回答
欢心
2楼-- · 2020-02-10 05:51

What about using popen?

查看更多
\"骚年 ilove
3楼-- · 2020-02-10 05:59
我只想做你的唯一
4楼-- · 2020-02-10 06:01
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();
查看更多
登录 后发表回答