设置startDetached()QProcess的环境变量 [英] Set Environment Variables for startDetached() QProcess
问题描述
但是,QProcess :: startDetached()是一个静态的成员函数,所以setProcessEnvironment()不适用。如何在Qt中为分离的进程设置Env变量?
这是一个已知的旧错误: http://bugreports.qt-project.org/browse/QTBUG-2284 。您需要重载 startDetached
函数来支持您自己的环境。看看Qt的来源,看看怎么做: http://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/io?h=5.5 ( 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?
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).
这篇关于设置startDetached()QProcess的环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!