Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt: Expand ~ to home-directory

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.

Edit:

Thank you all for the responses. "~/myfile" was just an example. What I am looking for is functionality to handle file-paths as you would be able to write on the command-line. So on Linux, it should accept "~/myfile", "~otheruser/hisfile", "$VAR/file" etc. On Windows, it should accept "%HOMEDIR%\myfile" etc.

like image 838
Rasmus Faber Avatar asked Dec 02 '09 14:12

Rasmus Faber


1 Answers

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

like image 103
ChristopheD Avatar answered Sep 23 '22 09:09

ChristopheD