I have main.cpp in which I want to call a C++ function to create image objects in QML during run time. How to add image objects in QML dynamically based on the input given in C++ function?
1 Answer
You could use an ImageProvider to provide the source for the Image-objects. Then you expose a C++ model to QML, that contains the identifiers for the ImageProvider.
Finally you use a Repeater/ListView/GridView... to instantiate Image-objects (delegate) and set the source to the modelData, so it loads the image from the ImageProvider
2 Comments
SSShet
Thank you so much, But I am really really new to this. Can anyone please give me a sample example so that I can continue from that? I have been trying this day and night for 3 straight days still I am not able to do it.
derM
It would take me some time, so I need to see, when I find this. I can't promise it.