美文网首页
QT 启动与关闭外部程序

QT 启动与关闭外部程序

作者: 听取哇声一片_11c4 | 来源:发表于2022-02-11 15:52 被阅读0次

启动

QString filepath = QDir::currentPath();

    QString fullpath = filepath+"\\pp\\dist\\start";

    QString title = fullpath+"\\main.exe";

    title = title.replace("/","\\");

    fullpath = fullpath.replace("/","\\");

    QProcess p(this);

    p.setWorkingDirectory(fullpath);

    p.start("cmd", QStringList()<<"/c"<<"start main.exe");

    p.waitForStarted();

    p.waitForFinished();

关闭

    QProcess p(this);

    p.setWorkingDirectory(fullpath);

    p.start("cmd", QStringList()<<"/c"<<"taskkill /f /t /im main.exe");

    p.waitForStarted();

    p.waitForFinished();

相关文章

网友评论

      本文标题:QT 启动与关闭外部程序

      本文链接:https://www.haomeiwen.com/subject/ckenkrtx.html