Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

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

    Installation and Deployment
    2
    3
    1061
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      dndeed last edited by

      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!

      1 Reply Last reply Reply Quote 0
      • A
        andreyc last edited by

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

        1 Reply Last reply Reply Quote 0
        • D
          dndeed last edited by

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

          1 Reply Last reply Reply Quote 0
          • First post
            Last post