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. Easy way to copy QSettings from NativeFormat to IniFormat
Forum Updated to NodeBB v4.3 + New Features

Easy way to copy QSettings from NativeFormat to IniFormat

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 3.1k 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
    AcerExtensa
    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?

    God is Real unless explicitly declared as Integer.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      AcerExtensa
      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...

      God is Real unless explicitly declared as Integer.

      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