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. how to remove .ini file
Qt 6.11 is out! See what's new in the release blog

how to remove .ini file

Scheduled Pinned Locked Moved Mobile and Embedded
13 Posts 4 Posters 10.8k 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.
  • S Offline
    S Offline
    Scylla
    wrote on last edited by
    #2

    I would use "bool QFile::remove()":
    @QFile file("/SeeCycleApp-build-desktop/debug/Unknown Organization.ini");
    file.remove();@

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #3

      To cite the documentation:

      bq. Removes the setting key and any sub-settings of key.

      Doen't sound like it takes a filename, does it?

      And to read further:

      bq. If key is an empty string, all keys in the current group() are removed.

      So why not give

      @
      settings.remove("");
      @

      a try?

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Scylla
        wrote on last edited by
        #4

        But I think he wants to remove the file and not the keys!?

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #5

          If he wants to reset the stored values, then calling remove("") is equivalent to removing the file.

          If removing the file is absolutely necessary, then one must be very careful to actually having a file to remove (do not remove the windows registry file...). And on a Mac it's different beast too. To actually remove the file, QFile::remove("path") is the way to go, that's right.

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Scylla
            wrote on last edited by
            #6

            Where can I find the information that remove(""), removes the file? I cannot find somthing like this in the documentation!

            1 Reply Last reply
            0
            • G Offline
              G Offline
              goetz
              wrote on last edited by
              #7

              Don't mix QSettings::remove() and QFile::remove().

              QSettings::remove with argument "" simply deletes all keys from the settings file, but the file is not deleted. That bascically resets the settings.

              QFile::remove() deletes a file from the hard disk.

              http://www.catb.org/~esr/faqs/smart-questions.html

              1 Reply Last reply
              0
              • S Offline
                S Offline
                Scylla
                wrote on last edited by
                #8

                So it was a simple misunderstanding!

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  goetz
                  wrote on last edited by
                  #9

                  This happens. Mixing to many removes sometimes causes a brain dump :)

                  http://www.catb.org/~esr/faqs/smart-questions.html

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    Scylla
                    wrote on last edited by
                    #10

                    But I was laughing by the thoughts about to remove the complete registry by using QSettings::remove("") ;-)

                    1 Reply Last reply
                    0
                    • B Offline
                      B Offline
                      BorahAnshuman
                      wrote on last edited by
                      #11

                      hello Scylla

                      Actually QFile::remove is working fine...but the thing is that when i change the address of my app its not working moreever when i build the application in the device its not working..so how can i do it so that whether i change the position or build in device it will remove the .ini file..

                      regards
                      Anshuman

                      1 Reply Last reply
                      0
                      • K Offline
                        K Offline
                        koahnig
                        wrote on last edited by
                        #12

                        Hi Anshuman,
                        when the location of your ini-file is changing all the time, this is not what you typically want with QSettings.
                        Therefore you have in Windows the possibility to use the registry, but this is sometimes less handy, because it is basically one file with the whole (registry) information of your installation.

                        You are using linux. In your example you have a fixed file name for your trial to remove the .ini-file. Check-out "QSettings":http://doc.qt.nokia.com/latest/qsettings.html#QSettings-4 . there you can use also a fixed name for opening the .ini-file. That is what you need anyhow. Changing locations of QSettings are not very helpful.

                        Vote the answer(s) that helped you to solve your issue(s)

                        1 Reply Last reply
                        0
                        • G Offline
                          G Offline
                          goetz
                          wrote on last edited by
                          #13

                          Why do you want to remove the file? This is completely contrary to what the persistence of QSettings is meant for.

                          http://www.catb.org/~esr/faqs/smart-questions.html

                          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