PDA

View Full Version : Save qpixmap to file



been_1990
8th June 2009, 21:48
Ok, now I can retrieve a icon from a file. :) How can I save it to a xml file?
Ex:

<icon>
<name>Explorer<name/>
<iconData> 011001010110101001001010110010101001110101110011
011001010110101001001010110010101001110101110011
011001010110101001001010110010101001110101110011
011001010110101001001010110010101001110101110011
011001010110101001001010110010101001110101110011
011001010110101001001010110010101001110101110011
011001010110101001001010110010101001110101110011
011001010110101001001010110010101001110101110011
011001010110101001001010110010101001110101110011
011001010110101001001010110010101001110101110011
<iconData/>
<icon/>

Thanks for all the help!

spirit
8th June 2009, 21:53
you can use this code for Qt Assistant to save a pixmap in a QBuffer


...
QPixmap pixmap;
QByteArray bytes;
QBuffer buffer(&bytes);
buffer.open(QIODevice::WriteOnly);
pixmap.save(&buffer, "PNG");
...

then you can convert QByteArray to base64 (using QByteArray::toBase64) and store in xml.

been_1990
11th June 2009, 18:36
Thank you.