Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Posts: 28
Registered: ‎02-07-2013
My Device: blackberry 10
My Carrier: vodafone
Accepted Solution

cascades passing GroupDataModel from c++ to qml problem!


 I am trying to access GroupDataModel data from c++ to qml!


I tried,


in hpp,

public Q_SLOTS:

bb::cascades::GroupDataModel load_datamodel(const QString& txprofile);


in cpp,

bb::cascades::GroupDataModel ApplicationUI::load_datamodel(const QString& txprofile)


GroupDataModel model;



return model;



But its not working! Please help me!


BlackBerry Development Advisor
Posts: 15,882
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: cascades passing GroupDataModel from c++ to qml problem!

I assume youare not seeing changes when the DataModel is updated?  I recommend exposing it to QML as a Q_PROPERTY like this:  


Q_PROPERTY(bb::cascades::DataModel* model READ model NOTIFY dataModelChanged)


	YourClass(QObject *parent = 0);


	 * This signal is emitted the data model is updated.
	void dataModelChanged();


	bb::cascades::DataModel* model() const;

	bb::cascades::GroupDataModel* mDataModel;


On the C++ side you could then fire the dataModelChanged signal after the model was changed and you want to refresh your UI.


Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: cascades passing GroupDataModel from c++ to qml problem!

we usually create the datamodel in c++ and use a q_invokable method to populate it from qml.
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter