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. Qsettings will not read ini when run from Qt Creator.
Forum Updated to NodeBB v4.3 + New Features

Qsettings will not read ini when run from Qt Creator.

Scheduled Pinned Locked Moved Solved Mobile and Embedded
8 Posts 4 Posters 1.1k 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.
  • A Offline
    A Offline
    AndreiS
    wrote on last edited by
    #1

    Hello,
    I am targeting an imx6 based device running embedded linux. The target will run my application on powerup. If I let the target power up, then I can read and write from settings.ini file with no problems. I then stop the application via SSH from my development machine and run the application from Qt Creator. When starting the app my QSettings wrapper class can not read any values and will always return the default. However, I can still write to the ini file when run from Qt Creator.

    The ini file has read/write permissions to the root user and read to others. What would stop the reading of values from QSettings when application is launched from Qt Creator? Yet still enable writing.

    Any feedback is much appreciated, thanks,

    raven-worxR 1 Reply Last reply
    0
    • A AndreiS

      Hello,
      I am targeting an imx6 based device running embedded linux. The target will run my application on powerup. If I let the target power up, then I can read and write from settings.ini file with no problems. I then stop the application via SSH from my development machine and run the application from Qt Creator. When starting the app my QSettings wrapper class can not read any values and will always return the default. However, I can still write to the ini file when run from Qt Creator.

      The ini file has read/write permissions to the root user and read to others. What would stop the reading of values from QSettings when application is launched from Qt Creator? Yet still enable writing.

      Any feedback is much appreciated, thanks,

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @AndreiS
      how exactly do you set the path to the ini file?
      If you just set the filename it is read from the current working directory (see QDir), which is probably not the same when running from QtCreator. But QtCreator provides an option field to set the remote working directory in the projects RUN settings.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      2
      • A Offline
        A Offline
        AndreiS
        wrote on last edited by
        #3

        There is a wrapper class where the file name is set in the constructor of QSettings. It's a hard coded path where we append onto app.applicationDirPath() . Again, what's strange is that I can write to the file when running from QtCreator. So I can run from QtCreator, make changes to ini, stop application, cycle target power, and the application will pick up the changes. Stop application, launch from QtCreator and changes are lost.

        Thanks,

        1 Reply Last reply
        0
        • A Offline
          A Offline
          AndreiS
          wrote on last edited by
          #4

          My apologies, this was self induced. Not sure why it was acting that way, but I fixed it. Please delete this topic. Thank you.

          Pablo J. RoginaP 1 Reply Last reply
          0
          • A AndreiS

            My apologies, this was self induced. Not sure why it was acting that way, but I fixed it. Please delete this topic. Thank you.

            Pablo J. RoginaP Offline
            Pablo J. RoginaP Offline
            Pablo J. Rogina
            wrote on last edited by
            #5

            @AndreiS said in Qsettings will not read ini when run from Qt Creator.:

            Please delete this topic

            No, please mark it as solved, and if possible, please explain a little better what you did to overcome the issue. Thanks.

            Upvote the answer(s) that helped you solve the issue
            Use "Topic Tools" button to mark your post as Solved
            Add screenshots via postimage.org
            Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            1
            • A Offline
              A Offline
              AndreiS
              wrote on last edited by
              #6

              I think this is what the issue was...
              I have a PLC communicating with my device over Modbus TCP. When the application starts it writes several pieces of data over modbus if the PLC is "connected". When I cycle power my target device comes to life before the PLC is "connected" and so it won't try and send the data. And all is well. When I run from QtCreator the PLC is ready, the data is sent, and I was attempting to do the following:

                  quint16 value;
                  m_settings->setValue(_lowerRatio,value);
              

              However, after this code it appears my _loweRatio key has been removed from the ini. Therefore, no longer available for reading later in the application. I must assume QSettings didn't like the quint16 because this works with an int.

              JonBJ 1 Reply Last reply
              0
              • A AndreiS

                I think this is what the issue was...
                I have a PLC communicating with my device over Modbus TCP. When the application starts it writes several pieces of data over modbus if the PLC is "connected". When I cycle power my target device comes to life before the PLC is "connected" and so it won't try and send the data. And all is well. When I run from QtCreator the PLC is ready, the data is sent, and I was attempting to do the following:

                    quint16 value;
                    m_settings->setValue(_lowerRatio,value);
                

                However, after this code it appears my _loweRatio key has been removed from the ini. Therefore, no longer available for reading later in the application. I must assume QSettings didn't like the quint16 because this works with an int.

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

                @AndreiS
                It would not be good if QSettings removed the key from the INI file if you pass it a quint16 rather than an int.

                From the first post in https://forum.qt.io/topic/35878/qvariant-does-not-support-int8-and-int16 you will see they may be serlialized as 32-bit, I don't know if that could affect your code anywhere, but the key should not get deleted from the INI file.

                A 1 Reply Last reply
                0
                • JonBJ JonB

                  @AndreiS
                  It would not be good if QSettings removed the key from the INI file if you pass it a quint16 rather than an int.

                  From the first post in https://forum.qt.io/topic/35878/qvariant-does-not-support-int8-and-int16 you will see they may be serlialized as 32-bit, I don't know if that could affect your code anywhere, but the key should not get deleted from the INI file.

                  A Offline
                  A Offline
                  AndreiS
                  wrote on last edited by
                  #8

                  @JonB Perhaps I'm mistaken and a quint16 does not remove the key, however it appeared that way. I moved on by storing my quint16 as an int, as you mentioned, and never looked back. Coincidentally, QSetting appears to be working as intended now. I will try and recreate the scenario (code & HW) and further test the claim that the key was being removed.

                  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