Writing QImage data to a XML file using QXmlStreamWriter



  • 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.



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



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



  • 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 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!



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.