Qt: 执行cmd命令;

    QProcess p(NULL);
    p.setWorkingDirectory(szAppPath+"/database");           //指定工作路径,这个地方一定要设置;
    p.start(szCmd);                        //开进程执行命令;
    while(p.state() != QProcess::NotRunning)                    //延时;
    {
        QTime delayTime = QTime::currentTime().addMSecs(100);
        while( QTime::currentTime() < delayTime)
           QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
    }            

  

posted @ 2019-04-10 14:36  时光旅者  阅读(3098)  评论(1编辑  收藏  举报