Problem with QDir::homePath()
[GNU/Linux, Qt 4.8]
in my environment, but
returns "/" instead of "/home/wl".
How comes? For debugging, I've also used getenv() at the very same place in the code, and it correctly returns "/home/wl".
Could you try what QDesktopServices::storageLocation(QDesktopServices::HomeLocation) returns?
It also returns "/".
Maybe a build issue? I'm running openSuSE factory; the installed Qt package is libqt4-4.8.0-245.2 (from obs://build.opensuse.org/KDE).
I don't know, sorry. According to the docs, it should return HOME from the environment. No idea why it doesn't in your case.
Have you tried stepping through QDir::homePath() to find out why it returns / ? As far as I know it is the fallback behaviour when the home directory couldn't be read for whatever reason.
The homePath is extracted from the HOME environment variable. If that is empty, the filesystem root is used:
QString home = QFile::decodeName(qgetenv("HOME"));
home = rootPath();
So it seems your HOME env variable got lost during application startup. You should check that with
qDebug() << qgetenv("HOME");
I figured, he already tried that:
[quote author="lemzwerg" date="1326958147"][GNU/Linux, Qt 4.8]
For debugging, I've also used getenv() at the very same place in the code, and it correctly returns "/home/wl".
My mistake. I interpreted UTF-16 as UTF-8, using
.constData()' instead ofqPrintable(...)'. Everything's fine now, and thanks to all of you for your help.