Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Config file with the package



  • Guys,

    I want to create a cross-platform application on mobile devices, both tablets and smartphones. The problem I could not solve is that I want to deliver my program with a json file holding some configuration data. I need to figure out:

    1. How to deploy an app with a custom file?
    2. How to read the deployed file?

    The solution must be independent from the platform. Therefore, it should not be a specific path when reading.


  • Lifetime Qt Champion

    Hi,

    Sounds like something for Qt's "resource":http://qt-project.org/doc/qt-5/resources.html system.

    For common paths on various platforms you have "QStandardPaths":http://qt-project.org/doc/qt-5/qstandardpaths.html



  • About the standard paths, I tried the following on an android device and get an empty string:

    @

    QString path(QStandardPaths::locate(
    QStandardPaths::DocumentsLocation,
    QString(),
    QStandardPaths::LocateDirectory));

    qDebug() << path;
    @

    Output:

    D/Qt (26137): ..\MobileMenu\mainwidget.cpp:15 (MainWidget::MainWidget(QWidget*)): ""

    Secondly, I have reviwed the documatation of it and I could not find any info for the IOS mobile devices. There are win, OSX, android, blackberry and linux only. Is it assumed that IOS and OSX are the same? "Link":http://qt-project.org/doc/qt-5/qstandardpaths.html

    UPDATE:
    I have succeeded in writing/reading by changing the "DocumentsLocation" to "DataLocation" :) However, I am still wondering if it will be working on IOS devices because of the reason I mentioned in the answers.


  • Lifetime Qt Champion

    The documentation is being updated for iOS


Log in to reply