简体   繁体   中英

Get general users desktop path in QT

I've been learning C++ for over 7 months in school now, so I would say that I'm pretty new to programming.

I'm currently working on a programm that, when it's done, should be able to create a .cfg file for CS : GO if no .cfg file exists OR edit your existing .cfg file, while not changing any of the settings you do not wish to change.

So, I want to save that .cfg to any users dekstop, but I can't seem to find any understandable explanation on how to get the general path to the desktop on Win10.

I created a QString autoexec; I want to save the users desktop path to, with autoexec.cfg at the end QString autoexec = "C:/Users/any_username/Desktop/autoexec.cfg";

To get your Desktop path on your OS you can use QStandardPaths

QString autoexec = 
          QString("%1/autoexec.cfg").arg(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM