How to convert QImage to QByteArray?
Try this:
QByteArray arr = QByteArray::fromRawData((const char*)img.bits(), img.byteCount());
You could do this:
QImage img_enrll;
QByteArray arr;
QBuffer buffer(&arr);
buffer.open(QIODevice::WriteOnly);
img_enrll.save(&buffer, "yourformat");
Having written that, if you need this for serialization, you are better of with QDataStream.