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. Regarding Using QSettings to read INI File
Qt 6.11 is out! See what's new in the release blog

Regarding Using QSettings to read INI File

Scheduled Pinned Locked Moved General and Desktop
48 Posts 12 Posters 77.5k Views 4 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 poojakamshetty

    This post is deleted!

    JonBJ Offline
    JonBJ Offline
    JonB
    wrote on last edited by JonB
    #39

    @poojakamshetty
    It helps if you use code tags for posting this here.

    values.insert(childKey, settings.value(childKey).toString());

    Don't you mean:

    QVector<QPair<QString, QString>> values;
    ...
    values.insert(i, QPair<QString, QString>(childKey, settings.value(childKey).toString()));
    

    ?

    Define yourself a type for QPair<QString, QString> and this will read easier.

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

      Hi,

      Since you really want a specific order, wouldn't it be simpler to sort your container after loading it with data ? That way you would be a bit less depending on the storage format.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      mrjjM 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Since you really want a specific order, wouldn't it be simpler to sort your container after loading it with data ? That way you would be a bit less depending on the storage format.

        mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by mrjj
        #41

        @SGaist
        Hi
        He wants same order as in the ini file so not sure we can sort it out by sorting ;)
        Unless you have something magic in mind?

        SGaistS 1 Reply Last reply
        0
        • mrjjM mrjj

          @SGaist
          Hi
          He wants same order as in the ini file so not sure we can sort it out by sorting ;)
          Unless you have something magic in mind?

          SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #42

          @mrjj said in Regarding Using QSettings to read INI File:

          @SGaist
          Hi
          He wants same order as in the ini file so not sure we can sort it out by sorting ;)
          Unless you have something magic in mind?

          Nothing magic, but if order is important then maybe sorting the container be a better idea than relying on something that can be modified with a text editor.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          mrjjM 1 Reply Last reply
          1
          • SGaistS SGaist

            @mrjj said in Regarding Using QSettings to read INI File:

            @SGaist
            Hi
            He wants same order as in the ini file so not sure we can sort it out by sorting ;)
            Unless you have something magic in mind?

            Nothing magic, but if order is important then maybe sorting the container be a better idea than relying on something that can be modified with a text editor.

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #43

            @SGaist
            Absolutely if the order has any logic to it.
            Also I'm not sure poster will find QVector easy to access compared to a
            map.

            1 Reply Last reply
            0
            • JonBJ JonB

              @poojakamshetty
              It helps if you use code tags for posting this here.

              values.insert(childKey, settings.value(childKey).toString());

              Don't you mean:

              QVector<QPair<QString, QString>> values;
              ...
              values.insert(i, QPair<QString, QString>(childKey, settings.value(childKey).toString()));
              

              ?

              Define yourself a type for QPair<QString, QString> and this will read easier.

              P Offline
              P Offline
              poojakamshetty
              wrote on last edited by
              #44

              @JonB using this I am getting error.

              jsulmJ 1 Reply Last reply
              0
              • P poojakamshetty

                @JonB using this I am getting error.

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

                @poojakamshetty said in Regarding Using QSettings to read INI File:

                I am getting error

                Don't you think you should post the actual error?!
                Or should we guess what the error is?

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

                P 1 Reply Last reply
                2
                • jsulmJ jsulm

                  @poojakamshetty said in Regarding Using QSettings to read INI File:

                  I am getting error

                  Don't you think you should post the actual error?!
                  Or should we guess what the error is?

                  P Offline
                  P Offline
                  poojakamshetty
                  wrote on last edited by
                  #46

                  @jsulm I am sorry, I thought I mentioned error.
                  main.cpp:29:13: error: no matching member function for call to 'insert'
                  qvector.h:147:10: note: candidate function not viable: requires 2 arguments, but 1 was provided
                  qvector.h:148:10: note: candidate function not viable: requires 2 arguments, but 1 was provided
                  qvector.h:235:21: note: candidate function not viable: requires 2 arguments, but 1 was provided
                  qvector.h:236:21: note: candidate function not viable: requires 2 arguments, but 1 was provided
                  qvector.h:149:10: note: candidate function not viable: requires 3 arguments, but 1 was provided
                  qvector.h:234:14: note: candidate function not viable: requires 3 arguments, but 1 was provided
                  This is an error.
                  values.insert(QPair<QString, QString>(childKey, settings.value(childKey).toString()));
                  At this line, I am getting that error.

                  jsulmJ 1 Reply Last reply
                  0
                  • P poojakamshetty

                    @jsulm I am sorry, I thought I mentioned error.
                    main.cpp:29:13: error: no matching member function for call to 'insert'
                    qvector.h:147:10: note: candidate function not viable: requires 2 arguments, but 1 was provided
                    qvector.h:148:10: note: candidate function not viable: requires 2 arguments, but 1 was provided
                    qvector.h:235:21: note: candidate function not viable: requires 2 arguments, but 1 was provided
                    qvector.h:236:21: note: candidate function not viable: requires 2 arguments, but 1 was provided
                    qvector.h:149:10: note: candidate function not viable: requires 3 arguments, but 1 was provided
                    qvector.h:234:14: note: candidate function not viable: requires 3 arguments, but 1 was provided
                    This is an error.
                    values.insert(QPair<QString, QString>(childKey, settings.value(childKey).toString()));
                    At this line, I am getting that error.

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

                    @poojakamshetty Please take a look at QVector documentation for insert() methods and fix your code. Hint: insert() has two parameters (as the error message already suggests).

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

                    1 Reply Last reply
                    5
                    • mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by
                      #48

                      Hi
                      Actually you might want to use append instead
                      https://doc.qt.io/qt-5/qvector.html#append
                      values.append(QPair<QString, QString>(childKey, settings.value(childKey).toString()));

                      1 Reply Last reply
                      4

                      • Login

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