01-21-2013 05:36 AM
Hi
I am new to cascades QML. My application has User Interfaces in QML and the business logic in C++. These two components need to communicate very frequently. For this I have opened some of my c++ objects to QML using :
qml->setContextProperty("_app", this);
This allows me to access all the public slots of _app in qml pages. But the problem is when c++ needs to notify QML how does it do it?
Currently, I have used the following method:
I have declared a property variable say loginStatus and an corresponding method onLoginStatusChanged() in qml. When I need to send any notification to qml I change the value of this variable in my c++ code (_app.loginStatus). This change in the value calls onLoginStatusChanged() method in qml where I take the necessary action.
QML Code :
property int loginStatus: _app.loginStatus
onLoginStatusChanged: {
console.log("LoginScreen.qml : Login status " + loginStatus);
//Take Action
}
Is this correct? Is there any other way where in I can directly call functions in QML from C++?
01-21-2013 05:59 AM
01-21-2013 07:25 AM
01-22-2013 04:55 AM
Thanks for Reply. I will try the connecting signals from c++ classes to qml screens approach.