作者:拥有勒幷不代表幸福_563 | 来源:互联网 | 2023-05-19 06:04
ifconfig|grepinetisworkingwhenexecutedviaterminal.ButnotviaQProcess是通过终端执行的。但不是通过Q
ifconfig | grep 'inet'
is working when executed via terminal. But not via QProcess
是通过终端执行的。但不是通过QProcess
My sample code is
我的示例代码
QProcess p1;
p1.start("ifconfig | grep 'inet'");
p1.waitForFinished();
QString output(p1.readAllStandardOutput());
textEdit->setText(output);
Nothing is getting displayed on textedit.
textedit没有显示任何东西。
but when I use just ifconfig
in start of qprocess, output is getting displayed on textedit. Did I miss any trick to construct the command ifconfig | grep 'inet'
, like use \'
for '
and \|
for |
? for special characters? but I tried that as well:(
但是当我在qprocess启动时使用ifconfig时,输出将显示在textedit上。我是否错过了构建命令ifconfig |“inet”的技巧,比如使用\“for”和\|为|?特殊字符?但是我也试过了
3 个解决方案