Communication between C++ and QML
I want to change the image on a Button via a C++ function (trigger a state-change or however it is done).
How can I achieve this?
For example you can emit signal from cpp, cennect to it in qml via Connection and do there whatever you want. Or you can change property of your object (but to do it you need to find it in objects tree).
Ah thank you. Can I find an example on this here?
One way is this:
You create a QObject derived class, that you give a property for the image URL, and make sure that property has a proper notify signal. Then, you put an instance of that class as a property in your QDeclarativeContext using setContextProperty. That makes the object accessible from within QML, where you can simply bind against the property name for the image URL.
Take a look at this "thread":http://developer.qt.nokia.com/forums/viewthread/4491/#30571 and get a checkout of the code from subversion that I made. This demonstrates exactly what you need.
Thanks everyone. I figured it out due to your help.