Qt Forum

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

    Writing QImage data to a XML file using QXmlStreamWriter

    General and Desktop
    2
    6
    4432
    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.
    • P
      ProudChild last edited by

      Im building an app in a lab that uses qt as base. We need to write an QImage data to xml file, and later on read that data, we are using QXmlStreamWriter, is there a way to write QImage as a CDATA or something like that with QXmlStreamWriter?

      thanks in advance.

      1 Reply Last reply Reply Quote 0
      • D
        DenisKormalev last edited by

        I suggest you to use base64-encoded image data in xml.

        1 Reply Last reply Reply Quote 0
        • P
          ProudChild last edited by

          ok, where do i start? is there a way to do that with QImages?

          1 Reply Last reply Reply Quote 0
          • D
            DenisKormalev last edited by

            Use QImage operators >> and << to serialize to/deserialize from QByteArray (using QDataStream) and use fromBase64()/toBase64() methods of QByteArray to store data in base64.
            Please, note that operator<< of QImage will not produce valid image data, it will only provide data to use in operator>>

            1 Reply Last reply Reply Quote 0
            • P
              ProudChild last edited by

              [quote author="Denis Kormalev" date="1311023269"]Use QImage operators >> and << to serialize to/deserialize from QByteArray (using QDataStream) and use fromBase64()/toBase64() methods of QByteArray to store data in base64.
              Please, note that operator<< of QImage will not produce valid image data, it will only provide data to use in operator>>[/quote]

              thank you very much for your helpful insight, i would never think of that on my own!

              1 Reply Last reply Reply Quote 0
              • D
                DenisKormalev last edited by

                ProudChild, you are welcome :) Assistant is not a strange heap of information, it is your friend in Qt development :)

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post