Jump to content

Converting QPixmap to QByteArray: Difference between revisions

From Qt Wiki
Convert ExpressionEngine links
Decode HTML entity names
Line 13: Line 13:
// Preparation of our QPixmap
// Preparation of our QPixmap
QByteArray bArray;
QByteArray bArray;
QBuffer buffer( &bArray );
QBuffer buffer( &bArray );
buffer.open( QIODevice::WriteOnly );
buffer.open( QIODevice::WriteOnly );
pixmap.save( &buffer, "PNG" );
pixmap.save( &buffer, "PNG" );
</code>
</code>



Revision as of 17:01, 12 March 2015

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