I am working on a program built with Qt 6.5.1 where I want to extend the PATH environment variable to include /usr/local/bin. This is the code I have come up with:
QProcess *process = new QProcess();
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
env.insert("PATH", env.value("PATH", "") + ":/usr/local/bin");
qDebug() << "env:" << env.value("PATH", "");
process->setProcessEnvironment(env);
QStringList environment = process->systemEnvironment();
qDebug() << "env:" << environment;
...
process->setProgram(programName);
process->setArguments(args);
process->start();
process->closeWriteChannel();
and the problem is that the change I make does not seem to stick to process -- my second debug output is totally void of the addition I made before the call to setProcessEnvironment.