QT运行cmd指令

运行cmd指令
QProcess p(0);
 p.start("route");//写入要运行的指令即可
 p.waitForStarted();
 p.waitForFinished();
 qDebug()<<QString::fromLocal8Bit(p.readAllStandardError());


另一种写法

 QProcess p(0);
 p.start("cmd", QStringList()<<"/c"<<"dir");//找网络ip的指令(netstat -aon|findstr 218.5.241.13:211)
 p.waitForStarted();
 p.waitForFinished();
 qDebug()<<QString::fromLocal8Bit(p.readAllStandardOutput());