QProcess 为 startDetached 设置环境变量

QProcess Set Environment Variables for startDetached

我想弄清楚如何在 Linux 中为 QProcess 的 startDetached 函数设置环境变量。我做了一个google,发现这是一个QT Bug and people have suggested workarounds on how to start a detached process and I could see some code to override the startDetached function in Windows set variables to detached qprocess

有人可以 post Unix 系统中需要如何完成此操作的代码。谢谢!!

由于子进程从父进程继承环境,我认为最简单的解决方法是 save/modify/restore 在 QProcess::startDetached() 前后使用 qgetenv()qputenv() 自己的环境打电话。