Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. getting qsettings to work properly
Qt 6.12 LTS is out! See what's new in the release blog

getting qsettings to work properly

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 632 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

    I have a profile which consists of Method names and its relation between each profile

    void Method::loadFrom(Settings &set, bool ownGroup)
    {
        Settings s("profiles.ini");
        s.beginGroup("Profiles");
        foreach (const QString &group, s.childGroups()) {
            s.beginGroup(group + " "+ m_filename);
            Profile *profile = new Profile();
            profile->setObjectName(group);
            profile->load(s);
            s.endGroup();
    
            m_currentProfileManager->m_Profiles << profile;
        }
        EraObject::staticLoadFrom(set, this, ownGroup);
    
    }
    
    void Method::saveTo(Settings &set, bool ownGroup, bool force)
    {
        Settings s("profiles.ini");
        s.beginGroup("Profiles");
        foreach(Profile * profile, m_currentProfileManager->m_Profiles) {
            s.beginGroup(profile->profilename());
            profile->save(s);
            s.endGroup();
        }
        s.endGroup();
        s.sync();
    
        EraObject::staticSaveTo(set, this, ownGroup, force);
    
    }
    Now the current profile is
    
    [Profiles]
    
        %20Default\Ta=@Variant(\0\0\0\x87\x41\xa0\0\0)
        %20Default\Te=@Variant(\0\0\0\x87\x42@\0\0)
        %20Default\Texp=@Variant(\0\0\0\x87\x42\x18\0\0)
        %20Default\dirty=0
        %20Default\lim1=@Variant(\0\0\0\x87\0\0\0\0)
        %20Default\lim2=@Variant(\0\0\0\x87\0\0\0\0)
        %20Default\objectName=" Default"
        %20Default\offset=@Variant(\0\0\0\x87\0\0\0\0)
        %20Default\profilename=" Default"
        yg\Ta=@Variant(\0\0\0\x87\x41\xa0\0\0)
        yg\Te=@Variant(\0\0\0\x87\x42@\0\0)
        yg\Texp=@Variant(\0\0\0\x87\x42\x18\0\0)
        yg\dirty=1
        yg\lim1=@Variant(\0\0\0\x87\0\0\0\0)
        yg\lim2=@Variant(\0\0\0\x87\0\0\0\0)
        yg\objectName=yg
        yg\offset=@Variant(\0\0\0\x87\0\0\0\0)
        yg\profilename=yg
        yu\Ta=@Variant(\0\0\0\x87\x41\xa0\0\0)
        yu\Te=@Variant(\0\0\0\x87\x42@\0\0)
        yu\Texp=@Variant(\0\0\0\x87\x42\x18\0\0)
        yu\dirty=1
        yu\lim1=@Variant(\0\0\0\x87\0\0\0\0)
        yu\lim2=@Variant(\0\0\0\x87\0\0\0\0)
        yu\objectName=yu
        yu\offset=@Variant(\0\0\0\x87\0\0\0\0)
        yu\profilename=yu
    

    I have for each Method name a profile, here its default and yu.

    I would like for each method name to generate its own profile and load it and save it. Currently all the methods load the same profile settings which is wrong.

    I want each method to have its own set of profiles.

    Method is just a qstring.

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

      Hi,

      Are you sure that all of your profiles contains different data besides the profile name ?

      Can you share your implementation of load and save ?

      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
      • Unsolved