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
Contributor
Posts: 33
Registered: ‎04-26-2010
My Device: Z10 / PlayBook 16GB
My Carrier: Verizon

Re: ListView no header

To remove the blank header for a one-level deep ListView, you can still use GroupDataModel, just set the grouping to None like this:
mStampModel->setGrouping(ItemGrouping::None);
Highlighted
Retired
Posts: 499
Registered: ‎05-07-2012
My Device: developer
My Carrier: developer

Re: ListView no header

Are all your issues solved?

There are several approaches here based on your needs; which did you pick?

 

Stuart

Developer
Posts: 206
Registered: ‎05-15-2012
My Device: None
My Carrier: Telus

Re: ListView no header

//Global in the .hpp file:
// A NavigationPane is used to create the drill down UI.
NavigationPane *mNav;

//.cpp file:

QList<QVariantMap> map;
QVariantMap variant;
Post* post; //Post is a custom object extending QVariant.
//Posts is a QList<Post*>
foreach (post, posts)
{
    variant.clear();
    variant.insert("link", post->link);
    variant.insert("id", post->id);

    map.insert(map.length(), variant);
}

ListView *List = mNav->findChild<ListView*>("List");

QListDataModel<QVariant> *model = new QListDataModel<QVariant>;
model->setParent(this);
model->clear();

QVariantMap v;
int i = 0;
foreach(v, map)
{
    model->insert(i,v);
    i++;
}
List->setDataModel(model);

 

Still fiddling around with getting the list QML to make it display properly, but this populates the ListView and sets the data model as one would expect.

 

Thanks for the help, everyone.

----------------------
Check out my app, Alien Flow for reddit

And of course, like my post if you found it helpful or informative!
Developer
Posts: 206
Registered: ‎05-15-2012
My Device: None
My Carrier: Telus

Re: ListView no header

It's probably worth noting there are simpler solutions than mine but using QVariantMap fit best with converting the JSON data I was receiving in to an object usable by a ListView.

----------------------
Check out my app, Alien Flow for reddit

And of course, like my post if you found it helpful or informative!