在Qt中调用CMD命令

1 QProcess p(0);  
2 p.start("cmd", QStringList()<<"/c"<<"ping www.baidu.com");  
3 p.waitForStarted();  
4 p.waitForFinished();  
5 QString strTemp=QString::fromLocal8Bit(p.readAllStandardOutput());  
6   
7 QMessageBox testMassage;  
8 testMassage.setText(strTemp);  
9 testMassage.exec();  

 

posted @ 2022-01-10 20:33  mcwhirr  阅读(1955)  评论(0)    收藏  举报