Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. qgetenv not working...
Forum Updated to NodeBB v4.3 + New Features

qgetenv not working...

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 971 Views 2 Watching
  • 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.
  • SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on last edited by
    #1

    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?

    Kind Regards,
    Sy

    1 Reply Last reply
    0
    • SPlattenS SPlatten

      @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.

      jsulmJ Online
      jsulmJ Online
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #6

      @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.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      SPlattenS 1 Reply Last reply
      2
      • jeremy_kJ Offline
        jeremy_kJ Offline
        jeremy_k
        wrote on last edited by
        #2

        Have you tried qEnvironmentVariable()?

        Asking a question about code? http://eel.is/iso-c++/testcase/

        SPlattenS 1 Reply Last reply
        0
        • jeremy_kJ jeremy_k

          Have you tried qEnvironmentVariable()?

          SPlattenS Offline
          SPlattenS Offline
          SPlatten
          wrote on last edited by SPlatten
          #3

          @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.

          Kind Regards,
          Sy

          jsulmJ 1 Reply Last reply
          0
          • SPlattenS SPlatten

            @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.

            jsulmJ Online
            jsulmJ Online
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #4

            @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.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            SPlattenS 1 Reply Last reply
            0
            • jsulmJ jsulm

              @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.

              SPlattenS Offline
              SPlattenS Offline
              SPlatten
              wrote on last edited by
              #5

              @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.

              Kind Regards,
              Sy

              jsulmJ 1 Reply Last reply
              0
              • SPlattenS SPlatten

                @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.

                jsulmJ Online
                jsulmJ Online
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #6

                @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.

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                SPlattenS 1 Reply Last reply
                2
                • jsulmJ jsulm

                  @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.

                  SPlattenS Offline
                  SPlattenS Offline
                  SPlatten
                  wrote on last edited by
                  #7

                  @jsulm , Just restarted Qt Creator and checked again, after the restart yes it's visible. And the code is working, thank you.

                  Kind Regards,
                  Sy

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved