I have tested it on Qt5.10 and it works well.
Encode -
Encode -
QStringToQImage(const QString msg)
{
QByteArray by = QByteArray::fromBase64(msg.toLatin1());
QImage img = QImage::fromData(by,"JPEG");
return img;
}
Decode -
QImageToQString(const QImage &image)
{
QByteArray byteArray;
QBuffer buffer(&byteArray);
image.save(&buffer, "JPEG"); // writes the image in JPEG format inside the buffer
QString iconBase64 = QString::fromLatin1(byteArray.toBase64().data());
return iconBase64;
}