Converting QPixmap to QByteArray: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
(Add "cleanup" tag)
Line 1: Line 1:
{{Cleanup | reason=Auto-imported from ExpressionEngine.}}
'''English''' [[Converting_QPixmap_to_QByteArray_Bulgarian|Български]]
'''English''' [[Converting_QPixmap_to_QByteArray_Bulgarian|Български]]



Revision as of 15:31, 3 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":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