【发布时间】:2021-09-29 17:35:08
【问题描述】:
我在 Qt 中开发了一个 GUI 应用程序。
这会运行一个带有 QProcess 的 Python 程序。
在myapp.h 文件中是公关定义:
QProcess *pr = new QProcess(this);
在构造函数中是这样的:
QString file = "program/path.py";
pr->start("[...]/Programs/Python/Python38-32/python.exe", QStringList() << file);
而析构函数有这样的代码:
pr->kill();
delete ui;
如果我运行这个程序,我没有错误。我关闭了窗口,但这个过程仍然运行,但我不知道为什么。
我在 Windows 中工作。
【问题讨论】:
-
QProcess::kill()在 Windows 上使用TerminateProcess。我会说你的代码没有运行。你用调试器检查了吗?