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. [SOLVED] Application settings for multiple versions on same machine
QtWS25 Last Chance

[SOLVED] Application settings for multiple versions on same machine

Scheduled Pinned Locked Moved General and Desktop
application setdifferent versi
5 Posts 2 Posters 2.2k Views
  • 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.
  • R Offline
    R Offline
    Rizzen
    wrote on last edited by Rizzen
    #1

    I am new to Qt after being told by a friend to try it out for a cross platform widget toolkit. I am using Qt Creator for coding, and but making use of CMake due to encountering limitations of QMake (which is great for simple structured applications). I also decide to use QML for fast prototyping development work, and I am totally amazed at the speed I can develop, constantly adding new bits and features.

    I having difficulty with application settings with different versions.

    I using QSettings class to handle the application settings, and have set QApplication's name, domain, and version properties before creating the QSettings object. I see the <application name>.ini being created under <domain name> directory, but it is being used by all the different versions of the application. This is causing problems when I running different versions, as some of settings have undergone changes between application versions. I seen various applications simply include the version numbers as part of the application directory name, and within the directory have settings .ini file with no version number as part of filename. Though Qt seem not to use directory for application settings container.

    How do I get QSettings to create a setting .ini file that includes the application version in the file name? For example app-0.5.ini and not just app.ini, so I can have settings app-0.5.ini and app-0.6.ini for application version 0.5 and 0.6.

    Also need to access the correct version settings file from QML. I can't see or figure out how to specify the settings file to use. I am using the Qt.application properties in About dialog window and other locations. I currently using Qt.labs.settings 1.0.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      AFAIK, you can't do it using a default constructed QSettings object however you should be able to do what you want using this constructor. Just concatenate the application and it's version number when creating the QSettings object and you should be good to go.

      Hope it helps

      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
      • R Offline
        R Offline
        Rizzen
        wrote on last edited by
        #3

        Thanx, this worked in creating and using the version based settings file in the C++ part of the application.

        Now I still have the issue with QML part to read the correct settings file. I can't seem to see anything in how to specify the application name, version, and domain. Currently nothing is being read, and I suspecting it is not finding the settings file for a specific application version.

        Documentation on Settings for QML is rather vague.

        1 Reply Last reply
        0
        • R Offline
          R Offline
          Rizzen
          wrote on last edited by
          #4

          Excellent news. I finally got a solution after plenty googling.

          Based on this post I manage to make a Settings object (extending QSettings) that uses the correct version of the application settings for QML part.

          Now both the C++ part and the QML part are accessing the correct version settings file.

          Remember: not to import Qt.labs.settings 1.0 as it will overwrite Settings object.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Nice ! Thanks for sharing :)

            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

            • Login

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