How do i code this right (Linux Only)
-
@
QDir dir("~/.MyProject");if (!dir.exists()) { dir.mkpath("~/.MyProject"); }
@
Doesn't Work or
@
QDir dir("$HOME/.MyProject");if (!dir.exists()) { dir.mkpath("$HOME/.MyProject");
@
But when i do
@
QDir dir("/home/myusername/.MyProject");if (!dir.exists()) { dir.mkpath("$/home/myusername/.MyProject");
@
it does work but it will only work for me and not other that i want to give my proect way to becuase it have my username not there so i can i fix it. :([[Marked up code and moved this out of the experimental QnA area, Tobias]]
-
You can get value of HOME variable using "getenv":http://www.cplusplus.com/reference/cstdlib/getenv/
-
I Found a way
@
QString UserHomeDir = (getenv("HOME"));
QString MyProjectDirExtension = ("/.MyProject");
QString MyProjectDir = (UserHomeDir + MyProjectDirExtension);
@[[marked up more code, Tobias]]
-
What about:
@
QDir::homePath()
@
? -
There is a reason why this section is called "QnA Testing Area": This is an experimental feature which may or may not survive.
Please do not use it for real questions.
-
Just use QDesktopServices::storageLocation(QDesktopServices::HomeLocation);