Converting QPixmap to QByteArray
Jump to navigation
Jump to search
English Български
Convert QPixmap to QByteArray
This is one way to convert "QPixmap":http://doc.qt.nokia.com/latest/qpixmap.html to "QByteArray":http://doc.qt.nokia.com/latest/qbytearray.html.
Useful when you want to store a pixmap in a database etc.
QPixmap pixmap;
// Preparation of our QPixmap
QByteArray bArray;
QBuffer buffer( &bArray );
buffer.open( QIODevice::WriteOnly );
pixmap.save( &buffer, "PNG" );
Now variable bArray contains the byte array form of pixmap.
Categories snippets