本文介绍了设置startDetached()QProcess的环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Qt4中,有QProcess :: setProcessEnvironment()用于为新产生的过程设置Env变量。



但是,QProcess :: startDetached()是一个静态的成员函数,所以setProcessEnvironment()不适用。如何在Qt中为分离的进程设置Env变量?

解决方案

这是一个已知的旧错误:。您需要重载 startDetached 函数来支持您自己的环境。看看Qt的来源,看看怎么做:( 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的环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 23:33