首页 > 代码库 > QT调用python脚本

QT调用python脚本

QProcess *proc = new QProcess();
proc->setEnvironment(proc->environment());
QString appPath = QCoreApplication::applicationDirPath();
proc->start(tr("sh ")+appPath+tr("/abc"));
//    proc->start(tr("python ")+appPath+tr("/generateHtmlOfDryRunReport.py")); 这种方法不知道为什么不可以
//    ui->dryRunFilePath->setText(tr("python ")+appPath+tr("/generateHtmlOfDryRunReport.py"));
ui->dryRunFilePath->setText(tr("sh ")+appPath+tr("/abc"));
proc->waitForStarted();

abc脚本:

#!/bin/bash
cd `dirname $0`
python generateHtmlOfDryRunReport.py

exit 0

 

QProcess::execute("python ./generateHtmlOfDryRunReport.py");

也能运行python脚本

QT调用python脚本