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. QSettings working on a QByteArray

QSettings working on a QByteArray

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 5.1k Views
  • 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.
  • L Offline
    L Offline
    luca
    wrote on last edited by
    #1

    Hi all,

    is there a way to use a QSettings from a file stored in a QByteArray?

    My idea is to put a lot of setting file in a DB and retrieve it with a query when needed. The query return me a QString or a QByteArray containing the setting file.

    Actually I must pass the QString to a QFile save it on a temporary file and pass the filename to a QSettings to use it:

    @
    QSettings setting("/tmp_dir/tmp_file.conf");
    @

    It should be useful to pass the QByteArray to the QSettings constructor.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sabrog
      wrote on last edited by
      #2

      You can use hard and long way - create custom implementation for QAbstractFileEngine and QAbstractFileEngineHandler. "Here":http://www.qtcentre.org/attachment.php?attachmentid=3501&d=1248628685 example from Wysota.

      Then you can just use own "prefix" like:

      @QSettings setting("MyFileEngineSystem:/file.conf");@

      QT - Apple QuickTime
      Qt - Nokia's Qt Development Frameworks
      Apple is a competitor of Nokia, so QT != Qt

      1 Reply Last reply
      0
      • L Offline
        L Offline
        luca
        wrote on last edited by
        #3

        [quote author="SABROG" date="1284108063"]You can use hard and long way - create custom implementation for QAbstractFileEngine and QAbstractFileEngineHandler. "Here":http://www.qtcentre.org/attachment.php?attachmentid=3501&d=1248628685 example from Wysota.

        Then you can just use own "prefix" like:

        @QSettings setting("MyFileEngineSystem:/file.conf");@[/quote]

        Thanks,

        Isn't there any easy and short way? :-)

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

          try this:

          @ bool readXmlFile(QIODevice &device, QSettings::SettingsMap &map);
          bool writeXmlFile(QIODevice &device, const QSettings::SettingsMap &map);

          int main(int argc, char *argv[])
          {
          const QSettings::Format XmlFormat =
          QSettings::registerFormat("xml", readXmlFile, writeXmlFile);

           QSettings settings(XmlFormat, QSettings::UserScope, "MySoft",
                              "Star Runner");
          
           ...
          

          }@

          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