I am developing a bb10 app in cascades. Here is the snippet for the header file
//applicationui.hpp
Q_PROPERTY(int metric READ getMetric WRITE setMetric NOTIFY metricChanged)
public:
int getMetric();
void setMetric(int newMetric);
signals:
void metricChanged(int);
private:
int m_metric;
//applicationui.cpp
ApplicationUI::ApplicationUI(bb::cascades::Application *app) :
QObject(app)
{
qml->setContextProperty("_app", this);
// Set created root object as the application scene
app->setScene(root);
m_metric = 1;
}
int ApplicationUI::getMetric(){
return m_metric;
}
void ApplicationUI::setMetric(int newMetric){
m_metric = newMetric;
emit metricChanged(m_metric);
}
In my main.qml I have a RadioGroup whose selectedIndex I would like to set depending on the metric value
RadioGroup {
id: distanceMetric
Option { id: option1; text: "Miles"}
Option { id: option2; text: "Kilometers"}
onCreationCompleted: {
distanceMetric.selectedIndex = _app.metric
}
}
But this doesnt seem to be working as expected. Any suggestions would be appreciated. Thanx