Reputation: 77
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?
Upvotes: 1
Views: 1275
Reputation: 13691
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
Upvotes: 1