Converting QPixmap to QByteArray

From Qt Wiki
Revision as of 15:31, 3 March 2015 by AutoSpider (talk | contribs) (Add "cleanup" tag)
Jump to navigation Jump to search
This article may require cleanup to meet the Qt Wiki's quality standards. Reason: Auto-imported from ExpressionEngine.
Please improve this article if you can. Remove the {{cleanup}} tag and add this page to Updated pages list after it's clean.

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