1 Star 2 Fork 2

LSuper / QtPacker

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
CmdProcess.cpp 1.17 KB
一键复制 编辑 原始数据 按行查看 历史
LSuper 提交于 2022-12-15 23:37 . fixed:1.rename pro file
#include "CmdProcess.h"
#include <QProcess>
#include "Log.h"
CmdProcess::CmdProcess(QObject *parent)
: QObject{parent},
p(new QProcess())
{
connect(p, &QProcess::readyReadStandardOutput, this, [=] {
emit readStandardOutput(p->readAllStandardOutput());
});
connect(p, &QProcess::readyReadStandardError, this, [=] {
emit readStandardError(p->readAllStandardError());
});
}
//1. D:/Qt/5.15.2/mingw81_64/bin/qtenv2.bat
//2. windeployqt D:/Code/QtProjects/process_test.exe
bool CmdProcess::StartProcess(const QString& envBatPath, const QString &appPath)
{
p->setProgram("cmd");
p->start();
p->waitForStarted();
auto bat = envBatPath + "\n";
QByteArray windeployqt = "windeployqt " + appPath.toLocal8Bit() + "\n";
p->write(bat.toLocal8Bit());
p->write(windeployqt);
qcout<< "state"<< p->state()<<"id"<<p->processId();
p->waitForFinished(1000);
//TODO:结束进程
p->terminate();
qcout<< "state"<< p->state();
// p->closeWriteChannel();
// if (!p->waitForFinished()) {
// qcout<<"QProcess run failed";
// emit error();
// return false;
// }
emit finished();
return true;
}
C++
1
https://gitee.com/l-super/qt-packer.git
git@gitee.com:l-super/qt-packer.git
l-super
qt-packer
QtPacker
master

搜索帮助