[SailfishDevel] XDG paths in QT

Andrey Kozhevnikov coderusinbox at gmail.com
Sun May 10 20:18:11 UTC 2015


Hello, you should use QStandardPaths. DataLocation is correct, it using 
applicationName and organizationName from you QGuiApplication instance.

11.05.2015 01:14, Nicolas Cisco пишет:
> Hi,
> i have some questions about what are the correct config and data paths 
> for an application.
> The harbour faq [ https://harbour.jolla.com/faq#2.4.0 ] says that for 
> these paths a subfolder during run time named <HARBOUR_APP_NAME> 
> inside a folder defined by the XDG Base Directory Specification should 
> be used. My question is how to get these values using QT.
> I though of using the QStandardPaths [ 
> http://doc.qt.io/qt-5/qstandardpaths.html ] or the QProcessEnvironment 
> [ http://doc.qt.io/qt-5/qprocessenvironment.html ] modules, but i 
> don't know if i am getting the correct values.
>
> Using the QStandardPaths module I get this output:
>
>     [D] main:66 - QStandardPaths::DataLocation:
>     "/home/nemo/.local/share/harbour-batzap/harbour-batzap"
>     [D] main:67 - QStandardPaths::GenericDataLocation:
>     "/home/nemo/.local/share"
>     [D] main:68 - QStandardPaths::CacheLocation:
>     "/home/nemo/.cache/harbour-batzap/harbour-batzap"
>     [D] main:69 - QStandardPaths::GenericCacheLocation:
>     "/home/nemo/.cache"
>     [D] main:70 - QStandardPaths::TempLocation: "/tmp"
>     [D] main:71 - QStandardPaths::ConfigLocation: "/home/nemo/.config"
>     [D] main:72 - QStandardPaths::GenericConfigLocation:
>     "/home/nemo/.config" 
>
> (i'm returning these values using: /qDebug() << 
> "QStandardPaths::<enum-name>: " << 
> QStandardPaths::writableLocation(QStandardPaths::<enum-name>);/
>
> According to the harbour faq, for application data the 
> $XDG_DATA_HOME/<harbour-name> folder should be used, ( freedesktop.org 
> <http://freedesktop.org> says that a possible value for $XDG_DATA_HOME 
> is "$HOME/.local/share/", so i'll assume that value, and assuming 
> <harbour-name> is "harbour-batsap") should the correct application 
> data folder be "/home/new/.local/share/harbour-batzap" 
> insted "/home/new/.local/share/harbour-batzap/harbour-batzap" as qt 
> returns for QStandardPaths::DataLocation?
>
> Note: the qt docs suggest that 
> /QStandardPaths::AppDataLocation/ should be used while 
> /QStandardPaths::DataLocation/ is a deprecated value. But i'm getting 
> errors (/AppDataLocation /is not a member of /QStandardPaths/) using 
> /QStandardPaths::AppDataLocation/ (it was introduced in Qt 5.4, i 
> really don't remember what Qt5 version jolla ships)
>
> If i try to get the values of the XDG variables using the 
> QProcessEnvironment module, i'm always getting blank values:
>
>     [D] main:75 -
>     QProcessEnvironment::systemEnvironment().value("$XDG_DATA_HOME"): ""
>     [D] main:76 -
>     QProcessEnvironment::systemEnvironment().value("XDG_DATA_HOME"): ""
>     [D] main:77 -
>     QProcessEnvironment::systemEnvironment().value("$XDG_CACHE_HOME"): ""
>     [D] main:78 -
>     QProcessEnvironment::systemEnvironment().value("XDG_CACHE_HOME"): ""
>     [D] main:79 -
>     QProcessEnvironment::systemEnvironment().value("$XDG_CONFIG_HOME"): ""
>     [D] main:80 -
>     QProcessEnvironment::systemEnvironment().value("XDG_CONFIG_HOME"): "" 
>
> (i'm returning these values using: /qDebug() << 
> "QProcessEnvironment::systemEnvironment().value(<variable>, "");/
> /
> /
> Using qDebug() << "getenv(<variable>): " << /getenv(<variable>);/ also 
> returns me an empty value:
>
>     [D] main:81 - getenv("XDG_DATA_HOME"):
>     [D] main:82 - getenv("$XDG_DATA_HOME"):
>     [D] main:83 - getenv("XDG_CACHE_HOME"):
>     [D] main:84 - getenv("$XDG_CACHE_HOME"):
>     [D] main:85 - getenv("XDG_CONFIG_HOME"):
>     [D] main:86 - getenv("$XDG_CONFIG_HOME"): 
>
> /
> /
> I'm executing the app thought qtcreator in my jolla device (deploying 
> it as an RPM package).
>
> What are the correct path values? and how should I get them throught qt?.
>
> Thanks!
> -- 
> Nicolas Cisco
> www.nckweb.com.ar <http://www.nckweb.com.ar>
>
>
> _______________________________________________
> SailfishOS.org Devel mailing list
> To unsubscribe, please send a mail to devel-unsubscribe at lists.sailfishos.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.sailfishos.org/pipermail/devel/attachments/20150511/308e9905/attachment-0001.html>


More information about the Devel mailing list