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. Getting the profile setting using QT settings
Qt 6.11 is out! See what's new in the release blog

Getting the profile setting using QT settings

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 1.4k 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.
  • A Offline
    A Offline
    AndreAhmed
    wrote on last edited by
    #1

    up vote
    0
    down vote
    favorite
    I'm using the Qt settings and it saves the object into a file. it saves to a file called sessionrc.

    Now I'm trying to load the object from the settings and save it back.

    The problem is I can not identify the object from the settings, so that I can load all the profiles that are saved.

    I'm using the following load and save functionality

    
    void ProfileManager::loadFrom(Settings &set, bool ownGroup)
    {
        qDebug()<<"LOAD";
        foreach (const QString &group, set.childGroups()) {
            if(group == "Profile")
            {
                Profile *profile = new Profile();
                profile->setObjectName(group);
                profile->loadFrom(set);
                m_Profiles << profile;
            }
        }
    
    
        EraObject::staticLoadFrom(set, this);
    
    }
    
    void ProfileManager::saveTo(Settings &set, bool ownGroup, bool force)
    {
        EraObject::staticSaveTo(set, this, ownGroup, force);
    
         foreach(Profile * profile, m_Profiles) {
            profile->saveTo(set);
        }
    
    }
    

    The current setting file is

    [www]
    Ta=20
    Te=48
    Texp=38
    lim1=0
    lim2=0
    offset=0
    profilename=www
    

    [www] is the profile that is saved. but I have many of it. How would I load it back and save it correctly

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

      Hi,

      Are you looking for something like described in QSettings::beginWriteArray ?

      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
      • A Offline
        A Offline
        AndreAhmed
        wrote on last edited by
        #3

        I don't think so.

        I have a profile class which has member variables that needs to be saved in the settings file and load them back.
        I need it to be like that
        [profiles]
        [profilename1]
        member variables

        [profilename2]
        member variables

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

          Then it looks like a group

          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

          • Login

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