[SOLVED]How to add an entry in settings app in iOS



  • I am developing a QtQuick application on iOS. The application is completed and working. However, I am currently using hard-coded IP/host information for external communication. Ideally, I would like to add an entry to the Settings that will allow me to supply a user-entered IP/host name. Can someone point me in the right direction?



  • Hi,

    in Qt 5.4 there the QML object Settings (Is a labs module so its interface could be changed in the future).
    I don't know if it is available also in iOS.



  • What about regular QSettings in C++? You can expose it (or a light wrapper class with strongly typed enumerated keys) as a context property to access it from QML if needed.



  • @DanWatkins I don't need to access the settings from QML. I can use the QSettings object from my C++ code which supports the QML no problem. What I am having a problem with now is that I don't see the settings entry in the iOS settings app, which is what I am trying to do. Here is the code I have so far:

    int main(int argc, char *argv[])
    {
      QGuiApplication app(argc, argv);
      
      TDA::TapDisplaySingleton* mainClass =
      new TDA::TapDisplaySingleton(&app);
      
      QObject::connect(&app, SIGNAL(aboutToQuit()),
                       mainClass, SLOT(aboutToQuitApp()));
      
      QGuiApplication::setOrganizationName("NASA Langley");
      QGuiApplication::setOrganizationDomain("larc.nasa.gov");
      QGuiApplication::setApplicationName("TAP Display");
      
      QSettings settings;
      settings.setValue("HOSTNAME", "localhost");
      
      QTimer::singleShot(10, mainClass, SLOT(run()));
      
      return app.exec();
    }
    

    When I run the app in simulator, and then check the Settings app, I don't see any entries for my program



  • Hi,

    as I said in the previous post I don't know if QSettings is supported in iOS.
    A different solution could be use Local Storage. (need to check is is available in iOS)



  • @mcosta I understood what you said, but the documentation for QSettings object seems to suggest it is supported for iOS. If people are writing apps for iOS using Qt, I can't imagine this particular task hasn't been necessary and resolved in some fashion



  • Using QSettings is not really meant to be used the way I was using it. The Apple way to do this is to create a Settings.bundle in your application, which includes a Root.plist file for specifying settings parameters and a Root.strings file for internationalization. To do this in Qt, you need to create the Root.plist and Root.strings file manually and then add the following to your Qt project file

    As it turns out, Qt does provide a way to generate a Settings.bundle file for your app. You need to define a Root.plist and Root.strings file in advance and then add the following to you .PRO file:

        SETTINGS_BUNDLE_DATA_ROOT.files += Root.plist
        SETTINGS_BUNDLE_DATA_ROOT.path = Settings.bundle
        SETTINGS_BUNDLE_DATA_LANG.files += Root.strings
        SETTINGS_BUNDLE_DATA_LANG.path = Settings.bundle/en.lproj
        QMAKE_BUNDLE_DATA += SETTINGS_BUNDLE_DATA_ROOT SETTINGS_BUNDLE_DATA_LANG
    

    The bundle will be created upon linking the app


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.