Welcome!

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

Reply
New Contributor
Posts: 7
Registered: ‎10-11-2009
My Device: Not Specified

How to use QDeclarativeListProperty to create a dynamic dropdown list

HI,

 

I created 

 

QDeclarativeListProperty * list = new QDeclarativeListProperty<bb::cascades::Option *>()
QList<bb::cascades::Option *> option = new QList<bb::cascades::Option *>();
 
Option* selection = new Option();
selection->create().text("sample1");
option->append(option);
 
//I have set upt the Q_PROPERTY TO BE:
Q_PROPERTY(QDeclarativeListProperty<bb::cascades::Option *> *option READ option CONSTANT);

 

 

My question is how to insert the Qlist<option> into the QDeclarativeListProperty<option>????

 

Thanks

 

 

 

Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: How to use QDeclarativeListProperty to create a dynamic dropdown list

Hi,

This page has sample code for QDeclarativeListProperty, maybe it will help:

http://qt-project.org/wiki/How_to_expose_lists_to_QML

 

It might be easier to directly export QList as a property. I'm not sure about this, but I think QDeclarativeListProperty is only needed when manipulating lists from QML side.

 

Even simpler approach is exporting a few functions to QML such as count() getItemAt(int index) etc to work with the list.

 


Andrey Fidrya, @zmeyc on twitter