Qt Creator and environment variables on Windows
-
This concerns runtime environment.
Question: I know how to set environment variables in Qt Creator "Preferences". But does Qt Creator set any runtime environment variables of its own when an application is started in Qt Creator, as opposed to a deployed environment without Qt Creator?
It would be nice if I could just query an existing variable instead of having to set it myself. That way, other developers would not have to remember to do this when they are maintaining my application.
-
Hi Robert,
Qt Creator sets environment variables on project level, not globally.
You can set a different environment for building and running.
Go project configuration, chose build or run settings and specify additional variables in the "Environment" section.
Check the documentation for more information.Cheers
Axel -
This concerns runtime environment.
Question: I know how to set environment variables in Qt Creator "Preferences". But does Qt Creator set any runtime environment variables of its own when an application is started in Qt Creator, as opposed to a deployed environment without Qt Creator?
It would be nice if I could just query an existing variable instead of having to set it myself. That way, other developers would not have to remember to do this when they are maintaining my application.
@Robert-Hairgrove said in Qt Creator and environment variables on Windows:
But does Qt Creator set any runtime environment variables of its own when an application is started in Qt Creator, as opposed to a deployed environment without Qt Creator?
All as @Axel-Spoerl has written, you can set your own from Creator. But are you asking specifically whether there is an environment variable auto-set by Creator when running from Creator, which you could test in your code if you want to know this? Because that was asked recently-ish and IIRC there is such a variable. Is that what you want, do you want me to go see if I can dig out the thread?
...OK, I couldn't resist, so I did a search. Surprise, surprise, it was your question! How to determine at runtime whether app is running launched by Qt Creator?. We talked about environment variables
QTC_RUNor_QTC_Path. Your question sounds to me like you are asking about this again, or is the angle here rather different? -
@Robert-Hairgrove said in Qt Creator and environment variables on Windows:
But does Qt Creator set any runtime environment variables of its own when an application is started in Qt Creator, as opposed to a deployed environment without Qt Creator?
All as @Axel-Spoerl has written, you can set your own from Creator. But are you asking specifically whether there is an environment variable auto-set by Creator when running from Creator, which you could test in your code if you want to know this? Because that was asked recently-ish and IIRC there is such a variable. Is that what you want, do you want me to go see if I can dig out the thread?
...OK, I couldn't resist, so I did a search. Surprise, surprise, it was your question! How to determine at runtime whether app is running launched by Qt Creator?. We talked about environment variables
QTC_RUNor_QTC_Path. Your question sounds to me like you are asking about this again, or is the angle here rather different?@JonB said in Qt Creator and environment variables on Windows:
an environment variable auto-set by Creator
Just write a launcher script that sets a variable before starting Creator.
@echo off set LAUNCHED_BY_QT_CREATOR=1 start "" "C:\Qt\Tools\QtCreator\bin\qtcreator.exe" pause -
@JonB said in Qt Creator and environment variables on Windows:
an environment variable auto-set by Creator
Just write a launcher script that sets a variable before starting Creator.
@echo off set LAUNCHED_BY_QT_CREATOR=1 start "" "C:\Qt\Tools\QtCreator\bin\qtcreator.exe" pause@Axel-Spoerl
Hi Axel. OP wrote:It would be nice if I could just query an existing variable instead of having to set it myself. That way, other developers would not have to remember to do this when they are maintaining my application.
So for his purposes he does not want (other) people to have to set an environment variable explicitly or by wrapping this in a
.batfile or similar, presumably.The more I read the question as phrased the more it seems to be the same as his linked previous question. I think we need to know just what he wants to answer best.