Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Easy way to copy QSettings from NativeFormat to IniFormat
Qt 6.12 LTS is out! See what's new in the release blog

Easy way to copy QSettings from NativeFormat to IniFormat

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 3.7k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hello,
    I have update-subprogram in my app and I'm about to merge settings from Windows registry(NativeFormat) to .ini file for more portability(to run from usb stick and save settings on it).

    is there any easy way to copy all keys, values, groups from one QSettings instance to another?

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      My current implementation looks like that:
      @
      QSettings s = new QSettings(QDir::toNativeSeparators(qApp->applicationDirPath()+"/settings.ini"),QSettings::IniFormat);

      if(s->allKeys().count() < 1)
      {
      QSettings tmp(QSettings::NativeFormat, QSettings::UserScope, "Firm", "App");
      if(tmp.allKeys().count() > 0)
      {
      QStringList keys = tmp.allKeys();
      for(unsigned int i = 0; i < keys.count(); i++)
      {
      s->setValue(keys.at(i), tmp.value(keys.at(i)));
      }
      }
      }
      @

      I'm wondering why is there nothing like QIODevice->copy or at least QSettings::allKeyValuePairs() like with headers in QNetworkRequest/QNetworkResponse...

      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