Issue
My app is called unwallpaper
and I would like to get its app data path:
qDebug() << QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
This return /home/sign/.local/share
on Linux but what should be returned is /home/sign/.local/share/<APPNAME>
, according to Qt Document
Should I set APPNAME value somewhere? I am using Qt Creator with qmake. Thanks!
Solution
According to the application name docs:
If not set, the application name defaults to the executable name (since 5.0).
It’s strange that the returned path didn’t contain the <APPNAME>
at all.
So a better approach is to explicitly set the application name and/or organization name like this:
QCoreApplication::setApplicationName("unwallpaper");
QCoreApplication::setOrganizationName("organization");
Answered By – kefir500
Answer Checked By – Pedro (BugsFixing Volunteer)