Skip to content

Consistent path separators for Qt

Qt uses "/" as a path separator internally. From the 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.

QDir::separator() is provided as a helper to write and feed paths to native, non-Qt functions:

You do not need to use this function to build file paths. If you always use "/", Qt will translate your paths to conform to the underlying operating system. If you want to display paths to the user using their operating system's separator use toNativeSeparators().

Until now, we were using a mixture of QDir::separator() and "/" as path separators. Let's be consistent about it, follow the Qt documentation, and use "/" from now on.

Edited by Dimitri Papadopoulos Orfanos

Merge request reports