[SOLVED]Using windows' environmental variables in the Qt code

  • Hi.

    I have a piece of code that needs to be able to access my environmental variables to create a path. I know how to make it work in the .pro file (INCLUDEPATH += "$$(NTTOOLS)/libcurl/trunk/include/curl" where NTTOOLS is the name of my variable) but I cannot seem to get it so I can access that variable in the actual c++ code.

    I have tried creating a variable in the .pro file that is equal to NTTOOLS and then using that in the code, but it's not working.

    Is there a way to view environmental variables in the code? if not, how do I access variables created in the pro file? I have looked online for this but haven't found much.

    Thanks in advance!

  • For runtime access to the environment variable take a look on "qgetenv()":http://qt-project.org/doc/qt-5/qtglobal.html#qgetenv

  • Perfect! Thank you, I knew there had to be an easy way to do it.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.