In Qt 5, the way you retrieve standard paths for a system has changed. Now, you use a special class named QStandardPaths instead of the desktop services class. By far my favorite use for this is locating directories without user interaction. In this quick example, we’ll locate the user’s home directory. Note that you can use any of the provided enums in replace of QStandardPaths::HomeLocation.
QString homeLocation = QStandardPaths::locate(QStandardPaths::HomeLocation, QString(), QStandardPaths::LocateDirectory);
This will return C:/Users/Admin on my development PC. This should work cross platform as well, so no more fiddling with the preprocessor to decide which default location to use. 🙂 You can replace the QString() with additional details for location.