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. What may be the error in following syntax?
Forum Updated to NodeBB v4.3 + New Features

What may be the error in following syntax?

Scheduled Pinned Locked Moved General and Desktop
8 Posts 6 Posters 2.5k 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.
  • P Offline
    P Offline
    pratik041
    wrote on last edited by
    #1

    @QSettings* s = new QSettings(QDir::currentPath() + "/my_file.ini" , QSettings::IniFormat);@

    Here if .ini file does not exist it should create new file but it is not creating.

    Pratik Agrawal

    1 Reply Last reply
    0
    • V Offline
      V Offline
      veeeee_d
      wrote on last edited by
      #2

      Check the path you're trying to create the file on.

      1 Reply Last reply
      0
      • P Offline
        P Offline
        pratik041
        wrote on last edited by
        #3

        i have checked the path is correct

        Pratik Agrawal

        1 Reply Last reply
        0
        • F Offline
          F Offline
          fluca1978
          wrote on last edited by
          #4

          Uhm..could it be a problem with the path separator? Have you tried to debug/print the real file name that is created?
          If that is correct, I will try to create an empty file in such directory to see if there is also a permission problem.

          1 Reply Last reply
          0
          • P Offline
            P Offline
            pratik041
            wrote on last edited by
            #5

            one thing i notice that if we will setvalue for the first time then only file will be created if it doesn't exist.

            Pratik Agrawal

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

              In the documentation you find:
              @Constructs a QSettings object for accessing the settings stored in the file called fileName, with parent parent. If the file doesn't already exist, it is created.
              @
              However, that is apparently not completely correct. I have just created an object with a fixed path and iniformat. I have not done anythingelse with that object. It was not created.
              When I set a value as you have as you have indicated, the ini-file will be created.

              So QSettings will only create a file, when information is available to be stored.

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

              1 Reply Last reply
              0
              • R Offline
                R Offline
                rcari
                wrote on last edited by
                #7

                Do you have write access to the QDir::currentPath() directory ?

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  Rahul Das
                  wrote on last edited by
                  #8

                  Code is ok. As koahnig told, it will create the ini file, only when you set a value.
                  If no values are there, you wouldn't need an empty file right ?


                  Declaration of (Platform) independence.

                  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