I want to start cmd.exe from a Qt app with a specific PATH set. I insert \"Path\" in QProcessEnvironment and set that environment to QProcess. Then I startDetached \"cmd\". On t
The startDetached method is a static method. So all the state that you applied to the process object is just ignored, because the method cannot see it. If you start the process with start() instead, the new process will pick up your environment.
process.start("cmd", args);
Of course, you want to the new process to be detached so that the parent can terminate without forcing the new process also to terminate. From what I can tell, the QProcess class does not offer you a way to achieve that easily. You could modify the environment of the parent process so that the new process inherits those modifications, but that does not sound at all desirable.
This question presents a possible workaround: Detaching a started process.