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. how can i parser the .ini file?
Forum Updated to NodeBB v4.3 + New Features

how can i parser the .ini file?

Scheduled Pinned Locked Moved Unsolved General and Desktop
27 Posts 4 Posters 15.3k 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.
  • J.HilkJ J.Hilk

    @victor-wang

    Quote from the docu:

    Platform-Specific Notes

    Locations Where Application Settings Are Stored

    As mentioned in the Fallback Mechanism section, QSettings stores settings for an application in up to four locations, depending on whether the settings are user-specific or system-wide and whether the settings are application-specific or organization-wide. For simplicity, we're assuming the organization is called MySoft and the application is called Star Runner.

    On Unix systems, if the file format is NativeFormat, the following files are used by default:

    $HOME/.config/MySoft/Star Runner.conf (Qt for Embedded Linux: $HOME/Settings/MySoft/Star Runner.conf)
    $HOME/.config/MySoft.conf (Qt for Embedded Linux: $HOME/Settings/MySoft.conf)
    /etc/xdg/MySoft/Star Runner.conf
    /etc/xdg/MySoft.conf

    The answer therefore is yes

    V Offline
    V Offline
    victor wang
    wrote on last edited by
    #16

    @J.Hilk
    So if my INI file is not at the default path i should move it in to the right path?
    Can't i give the direct path if i am not in the default path?

    jsulmJ 1 Reply Last reply
    0
    • V victor wang

      @J.Hilk
      So if my INI file is not at the default path i should move it in to the right path?
      Can't i give the direct path if i am not in the default path?

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

      @victor-wang "Can't i give the direct path if i am not in the default path?" - isn't it what I provided before?
      So here it is again:

      QSettings settings("/PATH_TO_MY_INI_FILE/my_ini_file.ini", QSettings::IniFormat);
      

      Just provide the complete path to the file, that's all.

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

      1 Reply Last reply
      0
      • J.HilkJ J.Hilk

        @victor-wang

        Quote from the docu:

        Platform-Specific Notes

        Locations Where Application Settings Are Stored

        As mentioned in the Fallback Mechanism section, QSettings stores settings for an application in up to four locations, depending on whether the settings are user-specific or system-wide and whether the settings are application-specific or organization-wide. For simplicity, we're assuming the organization is called MySoft and the application is called Star Runner.

        On Unix systems, if the file format is NativeFormat, the following files are used by default:

        $HOME/.config/MySoft/Star Runner.conf (Qt for Embedded Linux: $HOME/Settings/MySoft/Star Runner.conf)
        $HOME/.config/MySoft.conf (Qt for Embedded Linux: $HOME/Settings/MySoft.conf)
        /etc/xdg/MySoft/Star Runner.conf
        /etc/xdg/MySoft.conf

        The answer therefore is yes

        V Offline
        V Offline
        victor wang
        wrote on last edited by
        #18

        @J.Hilk
        http://doc.qt.io/qt-5/qsettings.html#setPath

        I think i can set the path myself by UserScope.
        But It has to be under /home.

        J.HilkJ 1 Reply Last reply
        0
        • V victor wang

          @J.Hilk
          http://doc.qt.io/qt-5/qsettings.html#setPath

          I think i can set the path myself by UserScope.
          But It has to be under /home.

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #19

          @victor-wang

          Either you have a hard time understanding what answeres are give to you, or you're messing with us ;-)

          So if my INI file is not at the default path i should move it in to the right path?

          That's a definite maybe.

          Can't i give the direct path if i am not in the default path?

          Yes:

          @J.Hilk said in [how can i parser the .ini file?](/topic/77013/how-can-i-parser-the-ini-

          QSettings settings("c:/Folder1/Folder2/..../my_ini_file.ini", QSettings::IniFormat);

          and

          @jsulm said in how can i parser the .ini file?:

          QSettings settings("/PATH_TO_MY_INI_FILE/my_ini_file.ini", QSettings::IniFormat);
          

          Just provide the complete path to the file, that's all.


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          V 1 Reply Last reply
          1
          • J.HilkJ J.Hilk

            @victor-wang

            Either you have a hard time understanding what answeres are give to you, or you're messing with us ;-)

            So if my INI file is not at the default path i should move it in to the right path?

            That's a definite maybe.

            Can't i give the direct path if i am not in the default path?

            Yes:

            @J.Hilk said in [how can i parser the .ini file?](/topic/77013/how-can-i-parser-the-ini-

            QSettings settings("c:/Folder1/Folder2/..../my_ini_file.ini", QSettings::IniFormat);

            and

            @jsulm said in how can i parser the .ini file?:

            QSettings settings("/PATH_TO_MY_INI_FILE/my_ini_file.ini", QSettings::IniFormat);
            

            Just provide the complete path to the file, that's all.

            V Offline
            V Offline
            victor wang
            wrote on last edited by
            #20

            @J.Hilk
            This is my code here
            And i got some error.
            Is there anything i need to fix?

            This is an error here

            Please help!

            FlotisableF 1 Reply Last reply
            0
            • V victor wang

              @J.Hilk
              This is my code here
              And i got some error.
              Is there anything i need to fix?

              This is an error here

              Please help!

              FlotisableF Offline
              FlotisableF Offline
              Flotisable
              wrote on last edited by
              #21

              @victor-wang
              the ; should not at the end of foreach statement, or it will do nothing and finish the foreach statement, just like for statement.

              you should write qDebug() not qDebug, you forget the parentheses.

              V 1 Reply Last reply
              0
              • FlotisableF Flotisable

                @victor-wang
                the ; should not at the end of foreach statement, or it will do nothing and finish the foreach statement, just like for statement.

                you should write qDebug() not qDebug, you forget the parentheses.

                V Offline
                V Offline
                victor wang
                wrote on last edited by
                #22

                @Flotisable
                Sorry, i got this :)

                Besides, i got a question.
                Can i only read the key which the value is true?

                FlotisableF 1 Reply Last reply
                0
                • V victor wang

                  @Flotisable
                  Sorry, i got this :)

                  Besides, i got a question.
                  Can i only read the key which the value is true?

                  FlotisableF Offline
                  FlotisableF Offline
                  Flotisable
                  wrote on last edited by
                  #23

                  @victor-wang
                  I think you have to write some code to test it, just read the key if it pass the test.

                  V 1 Reply Last reply
                  0
                  • FlotisableF Flotisable

                    @victor-wang
                    I think you have to write some code to test it, just read the key if it pass the test.

                    V Offline
                    V Offline
                    victor wang
                    wrote on last edited by
                    #24

                    @Flotisable
                    Can i put value into array?
                    If it can, how can i do it?

                    FlotisableF 1 Reply Last reply
                    0
                    • V victor wang

                      @Flotisable
                      Can i put value into array?
                      If it can, how can i do it?

                      FlotisableF Offline
                      FlotisableF Offline
                      Flotisable
                      wrote on last edited by
                      #25

                      @victor-wang
                      I think any data can be put into array, but what exactly you want ?

                      V 1 Reply Last reply
                      0
                      • FlotisableF Flotisable

                        @victor-wang
                        I think any data can be put into array, but what exactly you want ?

                        V Offline
                        V Offline
                        victor wang
                        wrote on last edited by
                        #26

                        @Flotisable
                        It is my code here

                        I wanna put childkey and values into array.
                        Then compare them.
                        But i don't know how to do it.
                        Please Help!

                        FlotisableF 1 Reply Last reply
                        0
                        • V victor wang

                          @Flotisable
                          It is my code here

                          I wanna put childkey and values into array.
                          Then compare them.
                          But i don't know how to do it.
                          Please Help!

                          FlotisableF Offline
                          FlotisableF Offline
                          Flotisable
                          wrote on last edited by
                          #27

                          @victor-wang
                          if you just want to test if the value is true, I think you can do it in the foreach statement, like

                            foreach( const QString &childkey, childkeys )
                              if( settings.value( childkey ).toString() == "true" )
                              {
                                // do what you want
                              }
                          
                          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