我在windows下用qt编程,想要执行一下cmd命令,如果用
- QProcess commandProcess;
- commandProcess.start("route", QStringList() << "print");
- QByteArray cmdoutput = commandProcess.readAllStandardOutput();
- QString txtoutput = cmdoutput;
这样在linux下是可以获取命令输出内容的,但是在windows下就不能了,也不知道执行了没有,返回字符串是空的。
于是我只能用system函数调用cmd命令了。
但是system函数返回的是int型的,而不是屏幕输出字符串。
大家有没有经验在windows下用qt获取返回字符串。请指点一二。
[ 此帖被zy_sunshine在2009-12-20 00:58重新编辑 ]