Converting QPixmap to QByteArray

From Qt Wiki
Revision as of 17:01, 12 March 2015 by AutoSpider (talk | contribs) (Decode HTML entity names)
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 to QByteArray.

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