zoukankan      html  css  js  c++  java
  • qt执行cmd命令

    源地址:http://blog.csdn.net/hn307165411/article/details/6858614

    运行 route、ipconfig 肯定没问题

    Copy code
         QProcess p(0);
         p.start("route");
         p.waitForStarted();
         p.waitForFinished();
         qDebug()<<QString::fromLocal8Bit(p.readAllStandardError());



    Copy code
         QProcess p(0);
         p.start("ipconfig");
         p.waitForStarted();
         p.waitForFinished();
         qDebug()<<QString::fromLocal8Bit(p.readAllStandardOutput());



    而 dir 是命令行提供的命令,不是程序!

    Copy code
         QProcess p(0);
         p.start("cmd");
         p.waitForStarted();
         p.write("dir ");
         p.closeWriteChannel();
         p.waitForFinished();
         qDebug()<<QString::fromLocal8Bit(p.readAllStandardOutput());


    Copy code
         QProcess p(0);
         p.start("cmd", QStringList()<<"/c"<<"dir");
         p.waitForStarted();
         p.waitForFinished();

         qDebug()<<QString::fromLocal8Bit(p.readAllStandardOutput());

  • 相关阅读:
    第八周上机
    第七周作业
    第七周上机练习
    第六周作业
    第六次上机
    第五次上机
    第四周作业
    第四周上机练习
    第三次作业
    第二次作业
  • 原文地址:https://www.cnblogs.com/findumars/p/5529527.html
Copyright © 2011-2022 走看看