Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. how to use QSetting with Mac App Groups
Forum Updated to NodeBB v4.3 + New Features

how to use QSetting with Mac App Groups

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.6k Views 1 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.
  • G Offline
    G Offline
    gietal
    wrote on 7 Sept 2017, 03:02 last edited by
    #1

    Hi,

    how would I go about saving user settings on mac group container with QSetting?

    reading the documentation it seems like QSetting only save the file in one of these location:

    • $HOME/Library/Preferences/com.MySoft.Star Runner.plist
    • $HOME/Library/Preferences/com.MySoft.plist
    • /Library/Preferences/com.MySoft.Star Runner.plist
    • /Library/Preferences/com.MySoft.plist

    for a sandboxed app, it would be something like:
    ~/Library/Containers/com.MySoft.Star Runner/Data/Library/Preferences/com.MySoft.Star Runner.plist

    but for app group, it should be something like:
    ~/Library/Group Containers/(teamID).com.MySoft.Star Runner/Library/Preferences/com.MySoft.Star Runner.plist

    is it possible for QSetting to save user settings in the group container ?

    more on mac app group: https://developer.apple.com/library/content/documentation/IDEs/Conceptual/AppDistributionGuide/AddingCapabilities/AddingCapabilities.html#//apple_ref/doc/uid/TP40012582-CH26-SW61

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 7 Sept 2017, 11:39 last edited by SGaist 9 Jul 2017, 19:31
      #2

      Hi and welcome to devnet,

      From a quick read through the related documentation, I don't see anything related to the App Groups stating that the application settings should reside there. On the contrary, it seems to be for sharing data (which settings are not) and/or inter process communication.

      After a second read, the documentation isn't the most clear about the handling of application settings. You can share settings for apps in a group using NSUserDefaults and thats the goal of the OP which is not the same as storing application specific settings.

      [Edit: fixed information]

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      G 1 Reply Last reply 7 Sept 2017, 17:51
      0
      • S SGaist
        7 Sept 2017, 11:39

        Hi and welcome to devnet,

        From a quick read through the related documentation, I don't see anything related to the App Groups stating that the application settings should reside there. On the contrary, it seems to be for sharing data (which settings are not) and/or inter process communication.

        After a second read, the documentation isn't the most clear about the handling of application settings. You can share settings for apps in a group using NSUserDefaults and thats the goal of the OP which is not the same as storing application specific settings.

        [Edit: fixed information]

        G Offline
        G Offline
        gietal
        wrote on 7 Sept 2017, 17:51 last edited by
        #3

        @SGaist thanks for the response,

        my situation is that I have 2 apps that I'd like to share some user defaults settings.
        in a native Mac app with Swift, we could easily achieve this by using:

        let sharedUserDefaults = UserDefaults(suiteName: "groupId.com.appGroupName")
        

        which will automatically create/load plist files located under:
        ~/Library/Group Containers/groupId.com.appGroupName/Library/Preferences/groupId.com.appGroupName.plist

        is there any alternative that does this with Qt?

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mpergand
          wrote on 7 Sept 2017, 19:02 last edited by mpergand 9 Jul 2017, 19:03
          #4

          Looking at the docs, i found:

          enum QSettings::Scope
          This enum specifies whether settings are user-specific or shared by all users of the same system.
          
          QSettings::UserScope 0
          Store settings in a location specific to the current user (e.g., in the user's home directory).
          QSettings::SystemScope 1
          Store settings in a global location, so that all users on the same machine access the same set of settings.
          

          Not tested ...

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 7 Sept 2017, 19:27 last edited by
            #5

            @gietal said in how to use QSetting with Mac App Groups:

            UserDefaults

            Thanks of the information. I somehow missed that one.

            After a quick verification in QSettings sources, I haven't seen anything specific for the App Group use case.

            However, what you can do is use Objective-C++ through NSUserDefaults and it init::suiteName method. Then you can use that class to manage your shared settings.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0

            2/5

            7 Sept 2017, 11:39

            • Login

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