在Qt(getenv等效)中展开环境变量 [英] Expand environment variables in Qt (getenv equivalent)

查看:736
本文介绍了在Qt(getenv等效)中展开环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在等待 getenv 功能。

推荐答案

Qt在getenv()周围有一个包装器,称为 qgetenv()

Qt has a wrapper around getenv(), called qgetenv().

QByteArray qgetenv ( const char * varName )

getenv()是一个标准函数,但Visual Studio已经弃用它,这是为什么Qt提供qgetenv()包装器。

getenv() is a standard function, but Visual Studio has deprecated it which is why Qt provides the qgetenv() wrapper.

请注意,如果您有兴趣获取标准文件系统位置(如主目录,应用程序数据目录等),您应该而是使用 QDesktopServices :: storageLocation()(Qt4)或 QStan dardPaths :: writableLocation()(Qt5)。

Note that if you're interested in getting standard filesystem locations (like the home directory, application data directory, etc.) you should instead use QDesktopServices::storageLocation() (Qt4) or QStandardPaths::writableLocation() (Qt5).

这篇关于在Qt(getenv等效)中展开环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆