1

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
  • Though it is old and for QtQuick 1.1, this might help you as an inspirational source: blog.qt.io/blog/2012/02/29/… Commented Dec 21, 2016 at 8:10

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

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.
It would take me some time, so I need to see, when I find this. I can't promise it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.