Use Image in qml from C++
-
I want to display an image in qml, I also need rotation, zoom, and stretching in height and width(fitToWidth and fitToHeight).
The C++ picture class has rotation and stretching methods, which is very important to me, but I didn’t find an object in qml Image, and so I’m trying to understand whether I can open an image in the C++ class, use its functions and then put it in qml display?
If I'm wrong and there is another way, I would be grateful if someone could explain it to me.
Thank you. -
I want to display an image in qml, I also need rotation, zoom, and stretching in height and width(fitToWidth and fitToHeight).
The C++ picture class has rotation and stretching methods, which is very important to me, but I didn’t find an object in qml Image, and so I’m trying to understand whether I can open an image in the C++ class, use its functions and then put it in qml display?
If I'm wrong and there is another way, I would be grateful if someone could explain it to me.
Thank you.@BlinCt I think QQuickImageProvider is your friend here if you want to use QImage API.
However, from transformations you mention all are available in QML, but under different names:
-
B BlinCt has marked this topic as solved on
-
@BlinCt I think QQuickImageProvider is your friend here if you want to use QImage API.
However, from transformations you mention all are available in QML, but under different names:
@sierdzio My question is, if I use QQuickImageProvider to work with an image, that is, with its help I will open the Image when I need to rotate it, zoom it. How can I transfer it to qml in order to work with it? In qml this object will not be an Image?
Thx for answer -
@sierdzio My question is, if I use QQuickImageProvider to work with an image, that is, with its help I will open the Image when I need to rotate it, zoom it. How can I transfer it to qml in order to work with it? In qml this object will not be an Image?
Thx for answer@BlinCt Please read the docs and it should become clear. On QML side, you still have an
Imagecomponent, you simply use a specific path which points to your image provider instance.Btw. yet another option for you, especially useful if you need to do some more advanced stuff: you can subclass QQuickPaintedItem and do the painting and image manipulations using QPainter.