How set source for Image - function on c++
-
wrote on 22 Nov 2019, 10:53 last edited by aha_1980
Hi!
I have function on c++, this function return QImage.
How I can set source for Image - this function? -
wrote on 22 Nov 2019, 10:55 last edited by
-
wrote on 22 Nov 2019, 12:27 last edited by
For not large images you can convert them to a string using Base64 format. Not optimal but kind of acceptable. For large images it is better to use QQuickImageProvider.
-
wrote on 22 Nov 2019, 13:11 last edited by Mihaill
I use this code, but Image in qml not use thes string.
How fix this?QString resultString; QByteArray ba; QBuffer bu(&ba); bu.open(QIODevice::WriteOnly); image.save(&bu, "PNG"); resultString = QString::fromLatin1(ba.toBase64().data()); qDebug()<<"resultString = QString::fromLatin1"<<resultString; return resultString;
And this too not work
resultString = ba.toBase64();
-
wrote on 22 Nov 2019, 13:41 last edited by
It is work
QString resultString; QByteArray ba; QBuffer bu(&ba); bu.open(QIODevice::WriteOnly); image.save(&bu, "PNG"); //resultString = QString::fromLatin1(ba.toBase64().data()); resultString = QString::fromLatin1("data:image/png;base64,") + QString::fromLatin1(ba.toBase64().data()); qDebug()<<"resultString = QString::fromLatin1"<<resultString; return resultString;
-
Hi!
I have function on c++, this function return QImage.
How I can set source for Image - this function?wrote on 23 Nov 2019, 03:59 last edited by@Mihaill using image provider class, the qt example shows it.
1/7