Qt wiki will be updated on October 12th 2023 starting at 11:30 AM (EEST) and the maintenance will last around 2-3 hours. During the maintenance the site will be unavailable.
Converting QPixmap to QByteArray
Jump to navigation
Jump to search
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.