11-23-2012 11:35 PM
There is a signal in the WeatherGuesserApp example that I am trying to userstand. The signal is onCityChanged in WeatherPage.qml. For the life of me I can figure out where the qml file(s) know that this signal has been declared. When I do something similar in my example, it tells me it is an unknown signal. If I comment out everything in the WeatherGuesserApp that deals with the signal in the hpp/cpp files, the IDE doesn't complain about the onCityChanged signal. Can someone please clarify how and where this signal is declared and visible to the QML code?
11-24-2012 08:39 AM
11-24-2012 09:35 AM
That is what I thought, but in my other posting,
This defining doesn't seem to work. It gives me an unknown signal error. When I comment out everything in the WeatherGuesserApp other than the onCityChanged in QML and signals: void cityChanged(QString city); I don't get the same error in QML. What am I missing?
11-24-2012 11:49 AM
Oh, I guess the "automatic connection" I mentioned works only with signals defined in the QML as well.
Notice that the WeatherPage defined in main.qml has a "city" property, bound to _homeModel.city. That _homeModel is set from a setContextProperty() in the c++ code, and the "city" property is defined as Q_PROPERTY(QString city READ city WRITE setCity NOTIFY cityChanged). That lets the QML code set up the binding, I believe.
12-14-2012 02:16 PM - edited 07-23-2013 01:46 PM
In order to expose C++ objects to QML you need to define a Q_PROPERY macro in the header of your HTTRead class.
For more information on how to expose C++ objects to QML, you can have a look at this part of the Cascades documenatiation: https://developer.blackberry.com/cascades/document
For more information on how to use the Qt property system, you can refer to the following documentation: