@ModelTech said in QProcess::execute works, QProcess::startDetached doesn't:
When I do a normal run, the QTemporaryFile is not created at all,
It does get created. I assume you have a stack-based QTemporaryFile object so that, "the file will subsequently be removed upon destruction of the QTemporaryFile object." So as you leave that scope the file vanishes. Whether your child process ever sees the file will simply be a race. I expect that the process starts faster than the code finishes the scope rarely, if ever.
Look at QTemporaryFile::setAutoRemove() to alter that behaviour. Your child process needs to clean up the temporary file itself.
while it does get created when I run stepwise in debug mode.
Yes, while you are paused inside the scope that contains the QTemporaryFile object the associated temporary file will exist.
But even then, there is a problem with the executed process in that Qt Creator seems to set PYTHONHOME which it shouldn't as that breaks the called process for using a different Python installation...
Qt Creator, by default, just passes on the environment it inherited. This is all configurable in the project settings.
[image: c53b7325-4428-47ae-b0fb-b37ea62f108b.png]
[image: aa7fe25b-7793-45bf-9edd-4a82ead35e91.png]