How send value in QImage to image source QML
-
Hi, thank you gave that answer
I want my picture taken from the database and set its value to QImage have send to Qml image(source:myimg), and displays it on.
I do not want to save the image. But I want to get it directly from C ++, and I send it to QmlQVariant currentImage = eQuery.value(5).toByteArray(); QByteArray bytes = currentImage.toByteArray(); QImage image; image.loadFromData(bytes); qDebug() << (image.width());
In the above code in a line of five width of the image, printed
So this means that the above code works pretty well .
And now my question is how much Qimage to return the Qml (image{source:...}). thanks -
If I understand you correctly, a
QQuickImageProvider
might be what you are looking for. http://doc.qt.io/qt-5/qquickimageprovider.html -
@MrErfan Did you not check you earlier deleted post ? It had a few answers.
@MrErfan To add to @neda's answer you can convert the image to base64 and set this as value to
Image
'ssource
property.
Something like:imageObj->setProperty("source", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAQvUlEQVRo3t2beYxd1X3Hv79zzr33LTNv3iwez+aNDOCw2WAMKSIgpTZJaUA0SkkrNWnTVhBFolG6pJIb2ihFFk3/aEBJF0VVk0pJS5eoCYVCYwjEwhTbY4PBi7A9tpkZ27O/W