Qt fast conversion path (slash and backslash conversion)

Creative Commons License Copyright: Attribution, allow others to create paper-based, and must distribute paper (based on the original license agreement with the same license Creative Commons )

Written using Qt cross-platform software, expressed in the path of linux and windows systems are different. This article describes a method how to quickly convert '/' and 'path.

/Turn \(turn slash backslash)

  • Use QDir::toNativeSeparatorsInterface
  • Example:
QString path = "C:/temp/test.txt";
path = QDir::toNativeSeparators(path);
  • Export
"C:\\temp\\test.txt"

\Turn /(turn slash backslash)

  • useQDir::fromNativeSeparators
  • Example:
QString path = "C:\\temp\\test.txt";
path = QDir::toNativeSeparators(path);
  • Export
C:/temp/test.txt

Guess you like

Origin blog.csdn.net/nicai_xiaoqinxi/article/details/92745287