Qt: Expand ~ to home-directory

后端 未结 2 1936
星月不相逢
星月不相逢 2021-01-17 17:43

Does Qt have any platform-independent functionality to accept paths like \"~/myfile\"?

I know about wordexp, but it would be nice with a platform-independent wrapper

相关标签:
2条回答
  • 2021-01-17 18:22

    I think that the absolutePath (http://doc.qt.io/qt-5/qdir.html#absolutePath) is the way to do it.

    0 讨论(0)
  • 2021-01-17 18:32

    You could probably just replace the tilde with the result of QDir::homePath()? Reference here.

    0 讨论(0)
提交回复
热议问题