qgetenv not working...
-
I have created an environment variable for my account as due to the lockdown on this laptop I cannot create a system environment variable.
It appears that qgetenv cannot access this because although I can see the variable exists when I check the list in a command prompt qgetenv returns "".
Is there a way to access environment variables defined in the logged in user profile?
-
@jsulm , From the Windows 10 start menu, I type env, then selected:
Edit environment variables for your account
From the Best match options. From the top User variables for simon.platten I clicked on the New... button and added a new environment variable which is visible in the dialog, also visible if I open a cmd prompt and type set.
-
Have you tried qEnvironmentVariable()?
-
Have you tried qEnvironmentVariable()?
@jeremy_k , thank you, I included the header:
#include <QtGlobal>
Although I see the function in the documentation, there is no version of:
qEnvironmentVariable
So it won't compile, perhaps because I'm stuck with Qt 5.9.2, sorry I should have said.
-
@jeremy_k , thank you, I included the header:
#include <QtGlobal>
Although I see the function in the documentation, there is no version of:
qEnvironmentVariable
So it won't compile, perhaps because I'm stuck with Qt 5.9.2, sorry I should have said.
-
@SPlatten How exactly did you add this environment variable and how exactly are you using qgetenv? Do you start your app from QtCreator? If so set that variable in Project/Run/Run Environment.
@jsulm , From the Windows 10 start menu, I type env, then selected:
Edit environment variables for your account
From the Best match options. From the top User variables for simon.platten I clicked on the New... button and added a new environment variable which is visible in the dialog, also visible if I open a cmd prompt and type set.
-
@jsulm , From the Windows 10 start menu, I type env, then selected:
Edit environment variables for your account
From the Best match options. From the top User variables for simon.platten I clicked on the New... button and added a new environment variable which is visible in the dialog, also visible if I open a cmd prompt and type set.
-
@SPlatten Did you log out and log in again after adding this variable?
And as I said before: when starting from QtCreator check whether this variable is visible in Project/Run/Run Environment.