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. Ini Files
Qt 6.11 is out! See what's new in the release blog

Ini Files

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 4 Posters 1.2k 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.
  • R Offline
    R Offline
    Redman
    wrote on last edited by
    #1

    Hello,

    What exactly happens to the ini files I use during development?
    When I install my application with cmake the resulting folder does not contain any of the ini files but the values are read correctly

    jsulmJ 1 Reply Last reply
    0
    • R Redman

      @jsulm I have some custom made ini files which I read from with QSettings. Nothing special, just some key, value pairs with string and boolean values. The ini files are registered in qrc. Is that the key factor as to why this might get built into my application, hence no need to have those ini files present anymore in the deployment folder?

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by
      #4

      @Redman
      If you have embedded the file as a resource in the executable then there is no external file.

      Beware! Such resource files can only be opened read-only, not for update, since they are embedded, A while ago I believe someone found this did not work with QSettings ini files, as, for right or for wrong, QSettings insists on opening for update, because settings can be altered. And I thought they reported this then failed on an embedded ini file. Have you verified your QSettings works opening such a file?

      R 1 Reply Last reply
      3
      • R Redman

        Hello,

        What exactly happens to the ini files I use during development?
        When I install my application with cmake the resulting folder does not contain any of the ini files but the values are read correctly

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @Redman Please explain better. What ini files? How do you use them? How do you install the ini files?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        R 1 Reply Last reply
        0
        • jsulmJ jsulm

          @Redman Please explain better. What ini files? How do you use them? How do you install the ini files?

          R Offline
          R Offline
          Redman
          wrote on last edited by
          #3

          @jsulm I have some custom made ini files which I read from with QSettings. Nothing special, just some key, value pairs with string and boolean values. The ini files are registered in qrc. Is that the key factor as to why this might get built into my application, hence no need to have those ini files present anymore in the deployment folder?

          JonBJ jsulmJ 2 Replies Last reply
          0
          • R Redman

            @jsulm I have some custom made ini files which I read from with QSettings. Nothing special, just some key, value pairs with string and boolean values. The ini files are registered in qrc. Is that the key factor as to why this might get built into my application, hence no need to have those ini files present anymore in the deployment folder?

            JonBJ Online
            JonBJ Online
            JonB
            wrote on last edited by
            #4

            @Redman
            If you have embedded the file as a resource in the executable then there is no external file.

            Beware! Such resource files can only be opened read-only, not for update, since they are embedded, A while ago I believe someone found this did not work with QSettings ini files, as, for right or for wrong, QSettings insists on opening for update, because settings can be altered. And I thought they reported this then failed on an embedded ini file. Have you verified your QSettings works opening such a file?

            R 1 Reply Last reply
            3
            • JonBJ JonB

              @Redman
              If you have embedded the file as a resource in the executable then there is no external file.

              Beware! Such resource files can only be opened read-only, not for update, since they are embedded, A while ago I believe someone found this did not work with QSettings ini files, as, for right or for wrong, QSettings insists on opening for update, because settings can be altered. And I thought they reported this then failed on an embedded ini file. Have you verified your QSettings works opening such a file?

              R Offline
              R Offline
              Redman
              wrote on last edited by
              #5

              @JonB So far the ini files get read correctly with QSettings on application start up. Qt 6.6.2.

              Thanks!

              1 Reply Last reply
              1
              • R Redman

                @jsulm I have some custom made ini files which I read from with QSettings. Nothing special, just some key, value pairs with string and boolean values. The ini files are registered in qrc. Is that the key factor as to why this might get built into my application, hence no need to have those ini files present anymore in the deployment folder?

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #6

                @Redman Files in recourse files are built into the executable. That also means that you can not change them at runtime. To do so you need to copy the ini files into a proper location if they are not yet present there and read/modify them there. To find proper config location use: https://doc.qt.io/qt-6/qstandardpaths.html#standardLocations with QStandardPaths::AppConfigLocation

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                1
                • S Offline
                  S Offline
                  SimonSchroeder
                  wrote on last edited by
                  #7

                  You can also provide default values for your settings. In that case you don't even have to include any ini files into qrc in the first place. Provide a path where ini files can be written instead.

                  1 Reply Last reply
                  1
                  • R Redman has marked this topic as solved on

                  • Login

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