Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    QSettings working on a QByteArray

    General and Desktop
    3
    4
    4775
    Loading More Posts
    • 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
      luca last edited by

      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 Reply Quote 0
      • S
        sabrog last edited by

        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 Reply Quote 0
        • L
          luca last edited by

          [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 Reply Quote 0
          • A
            alexander last edited by

            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 Reply Quote 0
            • First post
              Last post