Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Environment Variables for startDetached() QProcess

In Qt4, there is QProcess::setProcessEnvironment() for setting Env variables for the newly spawn process.

However, QProcess::startDetached() is a static member function, so setProcessEnvironment() doesn't apply. How does one set Env variables for a detached process in Qt?

like image 589
Shen Chen Avatar asked Oct 11 '25 11:10

Shen Chen


1 Answers

It is a known old bug: http://bugreports.qt-project.org/browse/QTBUG-2284. You need to overload startDetached function to support your own environment. Take a look at Qt sources to see how to do that: http://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/io?h=5.5 (qprocess* files).

like image 171
Giuseppe Cardone Avatar answered Oct 14 '25 20:10

Giuseppe Cardone



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!