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. qsetting array
Forum Updated to NodeBB v4.3 + New Features

qsetting array

Scheduled Pinned Locked Moved Solved Mobile and Embedded
24 Posts 4 Posters 12.6k 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.
  • S sandycoolxyz

    It need not be user specific.

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

    @sandycoolxyz Then use /home/USER_NAME/.YOUR_APP_NAME
    For example: /home/sandycoolxyz/.my_app
    The dot in front of my_app is important - it tells the system that the file is hidden (config files in user home directory are usually hidden).

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

    S 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #15

      Quoting myself:
      @SGaist said in qsetting array:

      You should consider using QStandardPaths to get the correct folder. The QStandardPaths::ConfigLocation would likely be fitting in your case.

      You'll then have your configuration file at the correct place whatever the OS you plan to support.

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

      S 1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #16

        Or use the second Settings constructor which takes a format and a scope. And it will all handle by itself.

        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
        0
        • jsulmJ jsulm

          @sandycoolxyz Then use /home/USER_NAME/.YOUR_APP_NAME
          For example: /home/sandycoolxyz/.my_app
          The dot in front of my_app is important - it tells the system that the file is hidden (config files in user home directory are usually hidden).

          S Offline
          S Offline
          sandycoolxyz
          wrote on last edited by
          #17

          @jsulm
          /home/user/ ..
          these are ROM. so can't write.

          jsulmJ 1 Reply Last reply
          0
          • S sandycoolxyz

            @jsulm
            /home/user/ ..
            these are ROM. so can't write.

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

            @sandycoolxyz ROM? How are you going to use this device? Do you really have many users there? What are the writeable locations/partitions?

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

            1 Reply Last reply
            0
            • S Offline
              S Offline
              sandycoolxyz
              wrote on last edited by
              #19

              The root file system is a read-only file system (SquashFS), so changing files in the root file system is not supported. In addition the directories /etc, /var and /tmp are relocated to writeable RAM at startup to allow data logging and configuration adjustment during runtime. Changes are not written back to NAND Flash and became destroyed at reboot. To change the standard configuration at every start (e.g. enable Ethernet interface), user startup scripts can be created and stored in writeable NAND Flash area.
              For persistent data storage a separate partition was created in NAND flash. This partition is mounted to /opt at every startup of the device. The subdirectories /opt/etc and /opt/share are created automatically by the operating system and held persistent configuration data (e.g. touch screen calibration data) and the font directory. Own data can be stored anywhere else in directory /opt.

              jsulmJ 1 Reply Last reply
              0
              • SGaistS SGaist

                Quoting myself:
                @SGaist said in qsetting array:

                You should consider using QStandardPaths to get the correct folder. The QStandardPaths::ConfigLocation would likely be fitting in your case.

                You'll then have your configuration file at the correct place whatever the OS you plan to support.

                S Offline
                S Offline
                sandycoolxyz
                wrote on last edited by
                #20

                @SGaist said in qsetting array:

                QStandardPaths::ConfigLocation

                #include <QStandardPaths> is from qt5.0 only.

                1 Reply Last reply
                0
                • S sandycoolxyz

                  The root file system is a read-only file system (SquashFS), so changing files in the root file system is not supported. In addition the directories /etc, /var and /tmp are relocated to writeable RAM at startup to allow data logging and configuration adjustment during runtime. Changes are not written back to NAND Flash and became destroyed at reboot. To change the standard configuration at every start (e.g. enable Ethernet interface), user startup scripts can be created and stored in writeable NAND Flash area.
                  For persistent data storage a separate partition was created in NAND flash. This partition is mounted to /opt at every startup of the device. The subdirectories /opt/etc and /opt/share are created automatically by the operating system and held persistent configuration data (e.g. touch screen calibration data) and the font directory. Own data can be stored anywhere else in directory /opt.

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

                  @sandycoolxyz That explains the behaviour you described.
                  But it doesn't tell anything about /home - is it on its own partition?
                  For global configuration you can use /opt/etc
                  "Own data can be stored anywhere else in directory /opt." - you should check the access rights there.

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

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #22

                    My bad, I forgot about the version you are using. Then it would be QDesktopService::storageLocation.

                    On a side note, if you are locked to Qt 4, please consider 4.8.7 which is the latest and last version of the Qt 4 series.

                    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
                    0
                    • S Offline
                      S Offline
                      sandycoolxyz
                      wrote on last edited by
                      #23
                      QSettings settings("/opt/example.ini",QSettings::IniFormat);
                      settings.beginWriteArray("arrayvalue");
                      settings.setArrayIndex(index);
                      settings.setValue("id",value);
                      settings.endArray();
                      settings.sync();
                      QProcess::execute( "/bin/sync" );
                      

                      I tried lot of things and this seems to work. But I did not understand why exactly.
                      Anyways thanks for you support.

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #24

                        Likely it depends on how your power cycled your device while testing your application.

                        If you just pushed some reset button, then then was no synchronisation done hence the data weren't written on the flash memory.

                        Disk write are not instantaneous, especially on such devices where there's a limit on how many times you can write on a given chip before blocks start to die. So you have to either gracefully restart your system or use sync like you did before going further. But beware, you should avoid triggering useless write on your flash memory.

                        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
                        2

                        • Login

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