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 edit a .ini file?
Forum Updated to NodeBB v4.3 + New Features

How to edit a .ini file?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
20 Posts 5 Posters 6.0k Views 2 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi,

    What is your current problem ?

    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
    1
    • S Sriu1

      I want to edit background-image field.
      Below is my code

      QSettings settings("/home/tel/weston.ini", QSettings::IniFormat);
      settings.beginGroup("shell");
      settings.setValue("background-image","myImage.png");
      settings.endGroup();

      Below is the ini file text


      [core]
      #modules=cms-colord.so
      #xwayland=true
      #shell=desktop-shell.so
      #gbm-format=xrgb2101010
      #require-input=true

      [shell]
      background-image=/home/tel/Documents/woman.jpg
      background-color=0xff002244
      background-type=tile
      clock-format=minutes
      panel-color=0x90ff0000
      locking=true
      animation=zoom
      startup-animation=fade
      #binding-modifier=ctrl
      #num-workspaces=6
      #cursor-theme=whiteglass
      #cursor-size=24

      icon=/usr/share/icons/hicolor/24x24/apps/google-chrome.png
      path=/usr/bin/google-chrome

      [launcher]
      icon=/usr/share/icons/gnome/24x24/apps/arts.png
      path=/home/tel/weston-4.0.0/weston-flower

      [input-method]
      path=/usr/local/libexec/weston-keyboard

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by
      #3

      @Sriu1 said in How to edit a .ini file?:

      background-image=/home/tel/Documents/woman.jpg

      Edit that line in a text editor?

      S 1 Reply Last reply
      0
      • JonBJ JonB

        @Sriu1 said in How to edit a .ini file?:

        background-image=/home/tel/Documents/woman.jpg

        Edit that line in a text editor?

        S Offline
        S Offline
        Sriu1
        wrote on last edited by Sriu1
        #4

        @JonB Yes.I want to edit "/home/tel/Documents/woman.jpg" to "myImage.png"

        JonBJ mrjjM 2 Replies Last reply
        0
        • S Sriu1

          @JonB Yes.I want to edit "/home/tel/Documents/woman.jpg" to "myImage.png"

          JonBJ Online
          JonBJ Online
          JonB
          wrote on last edited by
          #5

          @Sriu1
          So do so! We don't know what your problem is....

          1 Reply Last reply
          0
          • S Sriu1

            @JonB Yes.I want to edit "/home/tel/Documents/woman.jpg" to "myImage.png"

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

            @Sriu1
            But do you mean via code ?
            else you can simply open weston.ini in text editor and do it ?

            S 1 Reply Last reply
            0
            • mrjjM mrjj

              @Sriu1
              But do you mean via code ?
              else you can simply open weston.ini in text editor and do it ?

              S Offline
              S Offline
              Sriu1
              wrote on last edited by
              #7

              @mrjj I'm giving user an option to browse and change the background-image this new path I'm editing in weston.ini

              mrjjM JonBJ 2 Replies Last reply
              0
              • S Sriu1

                @mrjj I'm giving user an option to browse and change the background-image this new path I'm editing in weston.ini

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

                @Sriu1
                But the code you show, do not change background-image ?
                OR what is the actual issue currently or what you need help with ?

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  Sriu1
                  wrote on last edited by
                  #9

                  Hi @mrjj @JonB @SGaist ,
                  This is my code where I'm trying to edit only background-image=/home/tel/Documents/woman.jpg

                  QSettings settings("/home/tel/weston.ini", QSettings::IniFormat);
                  settings.beginGroup("shell");
                  settings.setValue("background-image","myImage.png");
                  settings.endGroup();

                  This is my weston.ini before running the code.

                  [core]
                  #modules=cms-colord.so
                  #xwayland=true
                  #shell=desktop-shell.so
                  #gbm-format=xrgb2101010
                  #require-input=true

                  [shell]
                  background-image=/home/tel/Documents/woman.jpg
                  background-color=0xff002244
                  background-type=tile
                  clock-format=minutes
                  panel-color=0x90ff0000
                  locking=true
                  animation=zoom
                  startup-animation=fade
                  #binding-modifier=ctrl
                  #num-workspaces=6
                  #cursor-theme=whiteglass
                  #cursor-size=24

                  #lockscreen-icon=/usr/share/icons/gnome/256x256/actions/lock.png
                  #lockscreen=/usr/share/backgrounds/gnome/Garden.jpg
                  #homescreen=/usr/share/backgrounds/gnome/Blinds.jpg
                  #animation=fade

                  [launcher]
                  icon=/usr/share/icons/gnome/24x24/apps/utilities-terminal.png
                  path=/usr/bin/gnome-terminal

                  [launcher]
                  icon=/usr/share/icons/gnome/24x24/apps/utilities-terminal.png
                  path=/usr/local/bin/weston-terminal

                  [launcher]
                  icon=/usr/share/icons/hicolor/24x24/apps/google-chrome.png
                  path=/usr/bin/google-chrome

                  [launcher]
                  icon=/usr/share/icons/gnome/24x24/apps/arts.png
                  path=/home/tel/weston-4.0.0/weston-flower

                  [input-method]
                  path=/usr/local/libexec/weston-keyboard

                  #[output]
                  #name=LVDS1
                  #mode=1680x1050
                  #transform=90
                  #icc_profile=/usr/share/color/icc/colord/Bluish.icc

                  #[output]
                  #name=VGA1
                  #mode=173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync
                  #transform=flipped

                  #[output]
                  #name=X1
                  #mode=1024x768@60
                  #transform=flipped-90

                  #[libinput]
                  #enable_tap=true

                  #[touchpad]
                  #constant_accel_factor = 50
                  #min_accel_factor = 0.16
                  #max_accel_factor = 1.0

                  [screen-share]
                  command=/usr/local/bin/weston --backend=rdp-backend.so --shell=fullscreen-shell.so --no-clients-resize

                  #[xwayland]
                  #path=/usr/local/bin/Xwayland


                  this is after running

                  [General]
                  background-image=myImage.png

                  [core]
                  %23gbm-format=xrgb2101010
                  %23modules=cms-colord.so
                  %23require-input=true
                  %23shell=desktop-shell.so
                  %23xwayland=true

                  [input-method]
                  %23constant_accel_factor=50
                  %23enable_tap=true
                  %23icc_profile=/usr/share/color/icc/colord/Bluish.icc
                  %23max_accel_factor=1.0
                  %23min_accel_factor=0.16
                  %23mode=1024x768@60
                  %23name=X1
                  %23transform=flipped-90
                  path=/usr/local/libexec/weston-keyboard

                  [launcher]
                  icon=/usr/share/icons/gnome/24x24/apps/arts.png
                  path=/home/tel/weston-4.0.0/weston-flower

                  [screen-share]
                  %23path=/usr/local/bin/Xwayland
                  command="/usr/local/bin/weston --backend=rdp-backend.so --shell=fullscreen-shell.so --no-clients-resize"

                  [shell]
                  %23animation=fade
                  %23binding-modifier=ctrl
                  %23cursor-size=24
                  %23cursor-theme=whiteglass
                  %23homescreen=/usr/share/backgrounds/gnome/Blinds.jpg
                  %23lockscreen=/usr/share/backgrounds/gnome/Garden.jpg
                  %23lockscreen-icon=/usr/share/icons/gnome/256x256/actions/lock.png
                  %23num-workspaces=6
                  animation=zoom
                  background-color=0xff002244
                  background-image=/home/tel/Documents/woman.jpg
                  background-type=tile
                  clock-format=minutes
                  locking=true
                  panel-color=0x90ff0000
                  startup-animation=fade


                  Please suggest why is it altering the complete ini file.

                  1 Reply Last reply
                  0
                  • S Sriu1

                    @mrjj I'm giving user an option to browse and change the background-image this new path I'm editing in weston.ini

                    JonBJ Online
                    JonBJ Online
                    JonB
                    wrote on last edited by JonB
                    #10

                    @Sriu1
                    OK, I think I might guess what you mean (not sure if you've changed code since original?). Do you mean: after you have gone settings.setValue("background-image","myImage.png"); you want that value saved back to the .ini file, and you're not seeing that happen? Then see http://doc.qt.io/qt-5/qsettings.html#isWritable, http://doc.qt.io/qt-5/qsettings.html#sync.

                    EDIT: Oh, now you're changing the question/information ... It's much better if you can do that in the first place...

                    I can only say %23 is the hex code for a #, and QSettings is choosing to save it encoded. You seem to be using # in your .ini file as a comment character. What makes you think that is acceptable to QSettings?

                    S 1 Reply Last reply
                    1
                    • JonBJ JonB

                      @Sriu1
                      OK, I think I might guess what you mean (not sure if you've changed code since original?). Do you mean: after you have gone settings.setValue("background-image","myImage.png"); you want that value saved back to the .ini file, and you're not seeing that happen? Then see http://doc.qt.io/qt-5/qsettings.html#isWritable, http://doc.qt.io/qt-5/qsettings.html#sync.

                      EDIT: Oh, now you're changing the question/information ... It's much better if you can do that in the first place...

                      I can only say %23 is the hex code for a #, and QSettings is choosing to save it encoded. You seem to be using # in your .ini file as a comment character. What makes you think that is acceptable to QSettings?

                      S Offline
                      S Offline
                      Sriu1
                      wrote on last edited by Sriu1
                      #11

                      @JonB I'm not creating any comments.That is the ini file generated by weston.The" # "are not created by me.
                      I'm just editing it
                      and why is this getting created
                      [General]
                      background-image=myImage.png

                      I want to edit here
                      [shell]
                      background-image=/home/tel/Documents/woman.jpg

                      Can you please send a code snippet?

                      JonBJ 1 Reply Last reply
                      0
                      • S Sriu1

                        @JonB I'm not creating any comments.That is the ini file generated by weston.The" # "are not created by me.
                        I'm just editing it
                        and why is this getting created
                        [General]
                        background-image=myImage.png

                        I want to edit here
                        [shell]
                        background-image=/home/tel/Documents/woman.jpg

                        Can you please send a code snippet?

                        JonBJ Online
                        JonBJ Online
                        JonB
                        wrote on last edited by
                        #12

                        @Sriu1
                        I don't know exactly why your settings.beginGroup("shell"); is not being taken into account. It's going into General because of:

                        In addition, if you save a top-level setting (a key with no slashes in it, e.g., "someKey"), it will appear in the INI file's "General" section.

                        So, if it were me, I would try for myself:

                        • Take out all the the # lines, at least temporarily while I test.
                        • Now try again with beginGroup(). Does it work now?
                        • If that doesn't work, try without beginGroup() and use shell/background-image instead.
                        • Does it work now?

                        If still not, you can ask with a minimal example, consisting now of just a couple of lines in the .ini file, instead of loads of irrelevant stuff.

                        I'm not creating any comments.That is the ini file generated by weston.The" # "are not created by me.
                        I'm just editing it

                        I'm pointing out that QSettings does not handle those lines in the way Windows/your "weston" does. Which may lead to problems.

                        S 1 Reply Last reply
                        0
                        • JonBJ JonB

                          @Sriu1
                          I don't know exactly why your settings.beginGroup("shell"); is not being taken into account. It's going into General because of:

                          In addition, if you save a top-level setting (a key with no slashes in it, e.g., "someKey"), it will appear in the INI file's "General" section.

                          So, if it were me, I would try for myself:

                          • Take out all the the # lines, at least temporarily while I test.
                          • Now try again with beginGroup(). Does it work now?
                          • If that doesn't work, try without beginGroup() and use shell/background-image instead.
                          • Does it work now?

                          If still not, you can ask with a minimal example, consisting now of just a couple of lines in the .ini file, instead of loads of irrelevant stuff.

                          I'm not creating any comments.That is the ini file generated by weston.The" # "are not created by me.
                          I'm just editing it

                          I'm pointing out that QSettings does not handle those lines in the way Windows/your "weston" does. Which may lead to problems.

                          S Offline
                          S Offline
                          Sriu1
                          wrote on last edited by
                          #13

                          @JonB Hi,Thanks for the reply
                          I tried this as you mentioned.
                          QSettings settings("/home/tel/weston.ini", QSettings::IniFormat);
                          settings.beginGroup("shell");
                          settings.setValue("shell/background-image","myImage.png");
                          settings.sync();
                          settings.endGroup();

                          My ini file after executing_________________

                          [core]
                          %23gbm-format=xrgb2101010
                          %23modules=cms-colord.so
                          %23require-input=true
                          %23shell=desktop-shell.so
                          %23xwayland=true

                          [input-method]
                          %23constant_accel_factor=50
                          %23enable_tap=true
                          %23icc_profile=/usr/share/color/icc/colord/Bluish.icc
                          %23max_accel_factor=1.0
                          %23min_accel_factor=0.16
                          %23mode=1024x768@60
                          %23name=X1
                          %23transform=flipped-90
                          path=/usr/local/libexec/weston-keyboard

                          [launcher]
                          icon=/usr/share/icons/gnome/24x24/apps/arts.png
                          path=/home/samhita/weston-4.0.0/weston-flower

                          [screen-share]
                          %23path=/usr/local/bin/Xwayland
                          command="/usr/local/bin/weston --backend=rdp-backend.so --shell=fullscreen-shell.so --no-clients-resize"

                          [shell]
                          %23animation=fade
                          %23binding-modifier=ctrl
                          %23cursor-size=24
                          %23cursor-theme=whiteglass
                          %23homescreen=/usr/share/backgrounds/gnome/Blinds.jpg
                          %23lockscreen=/usr/share/backgrounds/gnome/Garden.jpg
                          %23lockscreen-icon=/usr/share/icons/gnome/256x256/actions/lock.png
                          %23num-workspaces=6
                          animation=zoom
                          background-color=0xff002244
                          background-image=/usr/share/backgrounds/gnome/Aqua.jpg
                          background-type=tile
                          clock-format=minutes
                          locking=true
                          panel-color=0x90ff0000
                          shell\background-image=myImage.png
                          startup-animation=fade


                          This is getting created
                          shell\background-image=myImage.png

                          JonBJ 1 Reply Last reply
                          0
                          • S Sriu1

                            @JonB Hi,Thanks for the reply
                            I tried this as you mentioned.
                            QSettings settings("/home/tel/weston.ini", QSettings::IniFormat);
                            settings.beginGroup("shell");
                            settings.setValue("shell/background-image","myImage.png");
                            settings.sync();
                            settings.endGroup();

                            My ini file after executing_________________

                            [core]
                            %23gbm-format=xrgb2101010
                            %23modules=cms-colord.so
                            %23require-input=true
                            %23shell=desktop-shell.so
                            %23xwayland=true

                            [input-method]
                            %23constant_accel_factor=50
                            %23enable_tap=true
                            %23icc_profile=/usr/share/color/icc/colord/Bluish.icc
                            %23max_accel_factor=1.0
                            %23min_accel_factor=0.16
                            %23mode=1024x768@60
                            %23name=X1
                            %23transform=flipped-90
                            path=/usr/local/libexec/weston-keyboard

                            [launcher]
                            icon=/usr/share/icons/gnome/24x24/apps/arts.png
                            path=/home/samhita/weston-4.0.0/weston-flower

                            [screen-share]
                            %23path=/usr/local/bin/Xwayland
                            command="/usr/local/bin/weston --backend=rdp-backend.so --shell=fullscreen-shell.so --no-clients-resize"

                            [shell]
                            %23animation=fade
                            %23binding-modifier=ctrl
                            %23cursor-size=24
                            %23cursor-theme=whiteglass
                            %23homescreen=/usr/share/backgrounds/gnome/Blinds.jpg
                            %23lockscreen=/usr/share/backgrounds/gnome/Garden.jpg
                            %23lockscreen-icon=/usr/share/icons/gnome/256x256/actions/lock.png
                            %23num-workspaces=6
                            animation=zoom
                            background-color=0xff002244
                            background-image=/usr/share/backgrounds/gnome/Aqua.jpg
                            background-type=tile
                            clock-format=minutes
                            locking=true
                            panel-color=0x90ff0000
                            shell\background-image=myImage.png
                            startup-animation=fade


                            This is getting created
                            shell\background-image=myImage.png

                            JonBJ Online
                            JonBJ Online
                            JonB
                            wrote on last edited by
                            #14

                            @Sriu1
                            Since I specifically wrote: If you use shell/background-image, you must remove the beginGroup(). You ignored that and left it in? Please don't.

                            S 1 Reply Last reply
                            1
                            • JonBJ JonB

                              @Sriu1
                              Since I specifically wrote: If you use shell/background-image, you must remove the beginGroup(). You ignored that and left it in? Please don't.

                              S Offline
                              S Offline
                              Sriu1
                              wrote on last edited by
                              #15

                              @JonB Hi,
                              I tried this code

                              QSettings settings("/home/tel/weston.ini", QSettings::IniFormat);
                              settings.setValue("shell/background-image","myImage.png");
                              //settings.sync();
                              This is my ini

                              [core]
                              %23gbm-format=xrgb2101010
                              %23modules=cms-colord.so
                              %23require-input=true
                              %23shell=desktop-shell.so
                              %23xwayland=true

                              [input-method]
                              %23constant_accel_factor=50
                              %23enable_tap=true
                              %23icc_profile=/usr/share/color/icc/colord/Bluish.icc
                              %23max_accel_factor=1.0
                              %23min_accel_factor=0.16
                              %23mode=1024x768@60
                              %23name=X1
                              %23transform=flipped-90
                              path=/usr/local/libexec/weston-keyboard

                              [launcher]
                              icon=/usr/share/icons/gnome/24x24/apps/arts.png
                              path=/home/samhita/weston-4.0.0/weston-flower

                              [screen-share]
                              %23path=/usr/local/bin/Xwayland
                              command="/usr/local/bin/weston --backend=rdp-backend.so --shell=fullscreen-shell.so --no-clients-resize"

                              [shell]
                              %23animation=fade
                              %23binding-modifier=ctrl
                              %23cursor-size=24
                              %23cursor-theme=whiteglass
                              %23homescreen=/usr/share/backgrounds/gnome/Blinds.jpg
                              %23lockscreen=/usr/share/backgrounds/gnome/Garden.jpg
                              %23lockscreen-icon=/usr/share/icons/gnome/256x256/actions/lock.png
                              %23num-workspaces=6
                              animation=zoom
                              background-color=0xff002244
                              background-image=myImage.png
                              background-type=tile
                              clock-format=minutes
                              locking=true
                              panel-color=0x90ff0000
                              startup-animation=fade

                              jsulmJ 1 Reply Last reply
                              0
                              • S Sriu1

                                @JonB Hi,
                                I tried this code

                                QSettings settings("/home/tel/weston.ini", QSettings::IniFormat);
                                settings.setValue("shell/background-image","myImage.png");
                                //settings.sync();
                                This is my ini

                                [core]
                                %23gbm-format=xrgb2101010
                                %23modules=cms-colord.so
                                %23require-input=true
                                %23shell=desktop-shell.so
                                %23xwayland=true

                                [input-method]
                                %23constant_accel_factor=50
                                %23enable_tap=true
                                %23icc_profile=/usr/share/color/icc/colord/Bluish.icc
                                %23max_accel_factor=1.0
                                %23min_accel_factor=0.16
                                %23mode=1024x768@60
                                %23name=X1
                                %23transform=flipped-90
                                path=/usr/local/libexec/weston-keyboard

                                [launcher]
                                icon=/usr/share/icons/gnome/24x24/apps/arts.png
                                path=/home/samhita/weston-4.0.0/weston-flower

                                [screen-share]
                                %23path=/usr/local/bin/Xwayland
                                command="/usr/local/bin/weston --backend=rdp-backend.so --shell=fullscreen-shell.so --no-clients-resize"

                                [shell]
                                %23animation=fade
                                %23binding-modifier=ctrl
                                %23cursor-size=24
                                %23cursor-theme=whiteglass
                                %23homescreen=/usr/share/backgrounds/gnome/Blinds.jpg
                                %23lockscreen=/usr/share/backgrounds/gnome/Garden.jpg
                                %23lockscreen-icon=/usr/share/icons/gnome/256x256/actions/lock.png
                                %23num-workspaces=6
                                animation=zoom
                                background-color=0xff002244
                                background-image=myImage.png
                                background-type=tile
                                clock-format=minutes
                                locking=true
                                panel-color=0x90ff0000
                                startup-animation=fade

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

                                @Sriu1 Looks like it is working now?

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

                                1 Reply Last reply
                                0
                                • S Offline
                                  S Offline
                                  Sriu1
                                  wrote on last edited by
                                  #17

                                  but .ini is getting altered.The "#" starting lines are getting removed.

                                  JonBJ 1 Reply Last reply
                                  0
                                  • S Sriu1

                                    but .ini is getting altered.The "#" starting lines are getting removed.

                                    JonBJ Online
                                    JonBJ Online
                                    JonB
                                    wrote on last edited by
                                    #18

                                    @Sriu1
                                    Yes, as I said earlier:

                                    I can only say %23 is the hex code for a #, and QSettings is choosing to save it encoded. You seem to be using # in your .ini file as a comment character. What makes you think that is acceptable to QSettings?

                                    and

                                    I'm not creating any comments.That is the ini file generated by weston.The" # "are not created by me.
                                    I'm just editing it

                                    I'm pointing out that QSettings does not handle those lines in the way Windows/your "weston" does. Which may lead to problems.

                                    S 1 Reply Last reply
                                    0
                                    • JonBJ JonB

                                      @Sriu1
                                      Yes, as I said earlier:

                                      I can only say %23 is the hex code for a #, and QSettings is choosing to save it encoded. You seem to be using # in your .ini file as a comment character. What makes you think that is acceptable to QSettings?

                                      and

                                      I'm not creating any comments.That is the ini file generated by weston.The" # "are not created by me.
                                      I'm just editing it

                                      I'm pointing out that QSettings does not handle those lines in the way Windows/your "weston" does. Which may lead to problems.

                                      S Offline
                                      S Offline
                                      Sriu1
                                      wrote on last edited by
                                      #19

                                      @JonB Hi Thanks,
                                      The ini is weston generated.How to handle the # lines in it ?If I give the ini without # lines my application is not working.Please suggest

                                      JonBJ 1 Reply Last reply
                                      0
                                      • S Sriu1

                                        @JonB Hi Thanks,
                                        The ini is weston generated.How to handle the # lines in it ?If I give the ini without # lines my application is not working.Please suggest

                                        JonBJ Online
                                        JonBJ Online
                                        JonB
                                        wrote on last edited by JonB
                                        #20

                                        @Sriu1
                                        So if your .ini file is not acceptable wrt the #s after you have modified it via QSettings (which does not necessarily claim to be compatible with existing .ini file formats from what I can see, only compatible with its own reading & writing), and you or someone else cannot find a call to make it compatible, you seem to have 3 choices:

                                        • Do not use QSettings. Write your own reader/writer.
                                        • Use QSettings as the reader, but not the writer. Do your own writing instead.
                                        • Allow QSettings to write back. When finished, read the .ini file back as a text file and do your own substitution of %23s back to #s as you write it out as a text file.
                                        1 Reply Last reply
                                        2

                                        • Login

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