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
Developer
Posts: 411
Registered: ‎04-04-2012
My Device: BlackBerry Z30/Z10/Z10LE/Q10/PlayBook

ListView DataModel Subclass Question

I am trying to make a listview data model  subclass. I am looking at source examples and had a couple of questions.

 

1. What is the difference between using QListDataModel<QVariantMap> and QVariantListDataModel?

 

2. Do you have to use typedef or is this only for readability?

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

Re: ListView DataModel Subclass Question

1. QVariantListDataModel is defined as:

 

bb/cascades/databinding/qlistdatamodel.h:    typedef QListDataModel<QVariant> QVariantListDataModel;

 

2. typedefs are only for readability.

You can safely pass QListDataModel<QVariant> to a function expecting QVariantListDataModel, and so on.

 


Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 411
Registered: ‎04-04-2012
My Device: BlackBerry Z30/Z10/Z10LE/Q10/PlayBook

Re: ListView DataModel Subclass Question

So the answer to 1. is that they are the same. Correct?

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

Re: ListView DataModel Subclass Question

QVariantListDataModel is the same as QListDataModel<QVariant>.

QListDataModel<QVariantMap> is different!

QVariantMap is defined as QMap<QString, QVariant>.

Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 411
Registered: ‎04-04-2012
My Device: BlackBerry Z30/Z10/Z10LE/Q10/PlayBook

Re: ListView DataModel Subclass Question

Ok. Thanks. Missed the map part. I am looking at the bucket list example and the bucket model uses QListDataModel<QVariantMap> and when you generate a list with context example app, it uses QVariantListDataModel. I am trying to understand the difference and when to use the correct one.