Results 1 to 4 of 4

Thread: Get Windows User name

  1. #1
    Join Date
    Feb 2010
    Location
    Muscat
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Get Windows User name

    hi all,
    Hopefully a simple one. I’m trying to set my open file dialog to open on the desktop. I’ve got it working on my computer (running windows 7) by specifying C:/Users/Owner/Desktop/.
    After deploying the program on a machine running vista it seems this wont work and i need to specify the ‘Owner’ eg C:/Users/Eric/Desktop/.
    Can anyone help me with a function to get this?
    Yours in hope
    Crispy

  2. #2
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Get Windows User name

    First of all; I don't know how Win7 and Win Vista works.

    You can access to process Environment with
    QProcessEnvironment::systemEnvironment() and then read the value of %HOME% environment variable with QProcessEnvironment::value()
    A camel can go 14 days without drink,
    I can't!!!

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Get Windows User name

    QDesktopServices::storageLocation() with QDesktopServices::DesktopLocation.
    Last edited by ChrisW67; 4th May 2011 at 02:06.

  4. The following user says thank you to ChrisW67 for this useful post:

    Crispylx (4th May 2011)

  5. #4
    Join Date
    Feb 2010
    Location
    Muscat
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Get Windows User name

    Many thanks to both of you... and for your quick responses. I’m going to go with the QDesktopServices as it will be easier to drop into my existing code.

    Thanks again

Similar Threads

  1. Replies: 16
    Last Post: 28th February 2011, 09:34
  2. new user
    By sattu in forum Qt Programming
    Replies: 13
    Last Post: 17th September 2010, 06:14
  3. New user of QT
    By alvarovac in forum Newbie
    Replies: 2
    Last Post: 1st March 2010, 19:27
  4. Replies: 1
    Last Post: 16th November 2009, 07:10
  5. Replies: 2
    Last Post: 27th November 2008, 10:16

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.