View Full Version : qml qnd c++ integration

1st June 2011, 07:24
I have developed my whole GUI using QT qml. I have a lot of qml files and the flow is like that I am loading any new qml file from another qml file using page_loader... Now I want to integrate qml with c++ so that from c++ I will be able to change any qml properties.. I have used this code to integrate qml with c++:-

QDeclarativeView view;

ApplicationData data;
view.rootContext()->setContextProperty("applicationData", &data);

QGraphicsObject *rootObject = dynamic_cast<QGraphicsObject*>(view.rootObject());


return app.exec();

Now to change any property of qml file I added objectName in that qml file and then accessed that object from c++ using this code

QGraphicsObject *rect = rootObject->findChild<QGraphicsObject*>("mainText");
if (rect){
rect->setProperty("text", "Came here");

here "mainText" object name of one of the text element in the PasswordMain.qml file....

Till now its working and I am able to change any property of the file which I have set as a source in c++ code but the problem is that if I want to change any property of the page loaded from this PasswordMain.qml file then I am not able to change that using same process.... I am not getting any idea of how to change the properties of loaded qml page from c++.Please help me in this regard......Thanks in advance........

1st June 2011, 09:34
I think you need to repeat the whole process after the other file is loaded.