Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to save and read from .ini file using QSetting from the custom path
QtWS25 Last Chance

How to save and read from .ini file using QSetting from the custom path

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 3 Posters 3.3k 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.
  • E Offline
    E Offline
    econtech
    wrote on last edited by
    #1

    In Qt I am using QSettings class for savine and retrieving the application details. I saved the file as .ini format using QSettings. Also I saved the file in C://Program Files. But the file is created in the AppData/VirtualStore path. Is this is the expected behaviour.

    I want to save and retrieve the file from the custom path like C://Program Files/example/data. But I am not able to read the values from the path. Its always read from the /AppData/VirtualStore/ path.

    I am using windows 8 64 bit and Qt version 5.2.1.

    How I can save and read the .ini file in the custom path what I mentioned.

    Its very helpful any one of you give the solution for this problem.

    Thanks In Advance

    1 Reply Last reply
    0
    • T Offline
      T Offline
      Torgeir
      wrote on last edited by
      #2

      QSettings provides a constructor that takes a file name. Is that what you are using?

      Anyway, are you sure you want to save to C:\Program Files? Your application can only do this if it runs with elevated rights (as in "Run as Administrator")

      1 Reply Last reply
      0
      • E Offline
        E Offline
        econtech
        wrote on last edited by
        #3

        I copied the ini file into C://Program File/app/test path.

        Now I am reading the ini file using the above path. When i run the application the ini file is copied to AppData/Local/Virtual Store/.

        After that my application using the above path for reading the ini file.
        Now I changed the value in the ini file of my actual path C://Program File/app/test path.

        But the application still took the value from AppData/Local/Virtual Store/ path only.

        Is there any solution for solving the problem.

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

          Hi,

          Even with elevated rights you can't do everything. Ini files don't belong to the same folder as your application especially since you will be writing to it. You have a set of paths you can use (and that are recommended) You can retrieve them use QStandardPaths

          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

          • Login

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