Results 1 to 7 of 7

Thread: Accessing Environment Variables

  1. #1
    Join Date
    Jan 2006
    Location
    Maui, Hawaii
    Posts
    120
    Thanks
    65
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Accessing Environment Variables

    Hi,

    I'm trying to find a way of accessing some environment varibles. I thought I saw something somewhere in the docs about it, but I didn't see anything in QApplication.

    I hope to get out of doing a QProcess env command and searching through the results.


    Thanks!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Accessing Environment Variables

    How about ::getenv()? It should be implemented even on windows.

  3. The following user says thank you to jacek for this useful post:

    mhoover (21st September 2006)

  4. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Accessing Environment Variables

    You can also use the third argument to the main() function, just remember you get a copy of environment there.

  5. The following 2 users say thank you to wysota for this useful post:

    mhoover (21st September 2006), sunil.thaha (21st September 2006)

  6. #4
    Join Date
    Apr 2006
    Location
    San Francisco, CA
    Posts
    186
    Thanks
    55
    Thanked 12 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Accessing Environment Variables

    Quote Originally Posted by jacek View Post
    How about ::getenv()? It should be implemented even on windows.
    In Windows:
    Note: getenv is deprecated; consider using getenv_s instead

    You expected MS to break the mold, right?
    Software Engineer



  7. The following user says thank you to gfunk for this useful post:

    mhoover (21st September 2006)

  8. #5
    Join Date
    Jan 2006
    Location
    Maui, Hawaii
    Posts
    120
    Thanks
    65
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Accessing Environment Variables

    Thanks !! getenv works great.

    getenv_s must be windows because I can't compile with that command.

  9. #6
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Accessing Environment Variables

    You folks are Qt addicts aren't you? So , how about using qgetenv() instead? It provides portability and same features as the classic getenv() ...
    Current Qt projects : QCodeEdit, RotiDeCode

  10. The following user says thank you to fullmetalcoder for this useful post:

    mhoover (22nd September 2006)

  11. #7
    Join Date
    Mar 2006
    Posts
    9
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Accessing Environment Variables

    The only issue about qgetenv is that it is only defined in Qt version 4.X.

  12. The following user says thank you to Zatraz for this useful post:

    mhoover (22nd September 2006)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.