Run Linux commands from Qt4

我是研究僧i 提交于 2019-12-18 04:09:22

问题


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.


回答1:


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



回答2:


Use QProcess.




回答3:


What about using popen?



来源:https://stackoverflow.com/questions/2148185/run-linux-commands-from-qt4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!