Results 1 to 4 of 4

Thread: Qt or C++ system recognition function

  1. #1
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Qt or C++ system recognition function

    Hello!

    I would like to know if there is a Qt or else C++ function that returns the system of the computer in which my Qt software would be running (system = Linux, Windows, Mac, etc.).

    To give a context, the software I'm creating needs to create .txt achives and I want to use QDir to create this .txt files always in the same directory. But the best place for doing that would change from system to system, so, for example, if my software will be running by someone in Windows, it will create the space for the txt in "Programs and Settings", while if it is being running in Ubuntu, the txt will be created in /home. So I need to create a method in my software that recognizes which system is being used to create the appropriate path where the txts will be saved.

    Does anybody know a function for that?

    Thanks!

    Martin/Momergil

  2. #2
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Qt or C++ system recognition function

    QSysInfo will get you there.

    It's probably a better idea to use this as a default, but allow the user to set the location where they want such file stored.

  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: Qt or C++ system recognition function

    QDesktopServices will give you the recommended locations for various types of data without you having to worry about three different Windows flavours, Mac OS X, and Linux. Try QDesktopServices::DataLocation or QDesktopServices::CacheLocation

  4. #4
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt or C++ system recognition function

    Thank you! I'll try both to see which is best.

Similar Threads

  1. Replies: 5
    Last Post: 15th March 2011, 15:17
  2. system() function and QProgressBar
    By rajeshs in forum Qt Programming
    Replies: 10
    Last Post: 4th June 2008, 11:50
  3. Speech recognition?
    By gadnio in forum Qt Programming
    Replies: 3
    Last Post: 7th May 2007, 09:49
  4. User recognition
    By eu.x in forum Qt Programming
    Replies: 4
    Last Post: 13th March 2007, 03:16

Tags for this Thread

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.