Cross-platform way of constructing an FS path with Qt [duplicate]

扶醉桌前 提交于 2019-11-28 11:54:28
Adam W

You can either use "/" directly or use QDir::separator(). But in general use a QDir for this (which translates "/" to the platform specific path separator for you).

liaK

From Qt 4.6 QDir documentation,

Qt uses "/" as a universal directory separator in the same way that "/" is used as a path separator in URLs. If you always use "/" as a directory separator, Qt will translate your paths to conform to the underlying operating system.

So, I guess QDir will be helpful for you.

Just use "/" when staying in the Qt world. To convert the path for non-Qt classes and functions etc., use QDir::toNativeSeparators( path ).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!