PDA

View Full Version : Qt or C++ system recognition function



Momergil
27th July 2011, 19:49
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

SixDegrees
27th July 2011, 20:02
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.

ChrisW67
28th July 2011, 00:41
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

Momergil
28th July 2011, 22:01
Thank you! I'll try both to see which is best.