diff options
authorJesus Fernandez <>2017-03-05 17:28:56 +0100
committerJesus Fernandez <>2017-04-08 12:02:50 +0000
commit944bf6867f8360e7ec79f542f65b4ea556ecc4e5 (patch)
parent4a6cb89f2944b5d8ee3e50fd3a2085eba9189680 (diff)
Add more information about how to get a QString from qgetenv
Change-Id: Ic712654c8d4735a59bf02cf6a7e1c689ca9a886c Reviewed-by: Thiago Macieira <>
1 files changed, 4 insertions, 0 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 54df8b1f61..6b3cb502e5 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -3220,12 +3220,16 @@ static QBasicMutex environmentMutex;
Returns the value of the environment variable with name \a
varName. To get the variable string, use QByteArray::constData().
+ To convert the data to a QString use QString::fromLocal8Bit().
\note qgetenv() was introduced because getenv() from the standard
C library was deprecated in VC2005 (and later versions). qgetenv()
uses the new replacement function in VC, and calls the standard C
library's implementation on all other platforms.
+ \warning Don't use qgetenv on Windows if the content may contain
+ non-US-ASCII characters, like file paths.
\sa qputenv(), qEnvironmentVariableIsSet(), qEnvironmentVariableIsEmpty()
QByteArray qgetenv(const char *varName)