Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. [SOLVED]How to add an entry in settings app in iOS
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Mobile and Embedded
7 Posts 3 Posters 2.6k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DRoscoe
    wrote on last edited by DRoscoe
    #1

    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?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mcosta
      wrote on last edited by
      #2

      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.

      Once your problem is solved don't forget to:

      • Mark the thread as SOLVED using the Topic Tool menu
      • Vote up the answer(s) that helped you to solve the issue

      You can embed images using (http://imgur.com/) or (http://postimage.org/)

      1 Reply Last reply
      0
      • D Offline
        D Offline
        DanWatkins
        wrote on last edited by
        #3

        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.

        D 1 Reply Last reply
        0
        • D DanWatkins

          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.

          D Offline
          D Offline
          DRoscoe
          wrote on last edited by
          #4

          @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

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mcosta
            wrote on last edited by
            #5

            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)

            Once your problem is solved don't forget to:

            • Mark the thread as SOLVED using the Topic Tool menu
            • Vote up the answer(s) that helped you to solve the issue

            You can embed images using (http://imgur.com/) or (http://postimage.org/)

            D 1 Reply Last reply
            0
            • M mcosta

              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)

              D Offline
              D Offline
              DRoscoe
              wrote on last edited by
              #6

              @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

              1 Reply Last reply
              0
              • D Offline
                D Offline
                DRoscoe
                wrote on last edited by
                #7

                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

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved