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: 11
Registered: ‎08-28-2012
My Device: 9800
My Carrier: --

ListView basics

[ Edited ]

Hello,

I need to create very simple ListView from the cpp file (not load from XML or some database). It should look like this

 

I tried something like:

ListView* listview = root->findChild<ListView *>("listview");

GroupDataModel *model = new GroupDataModel(QStringList() << "header" << "item");
 
QVariantMap map;
map["header"] = "My header";
map["item"] = "My item"; 
model->insert(map);

listview->setDataModel(model);

 where my ListView is just

ListView {
    objectName: "listview"
}

 It compiles fine, but then I get error

 

ERROR:: QNXPpsSubscriptionServer: QNXPpsSubscriptionServer::createObject: (13) Failed to create dir /pps/services/automation/framework

ERROR:: QNXPpsSubscriptionServer: QNXPpsSubscriptionServer::subscribe: Failed to open /pps/services/automation/framework/control?delta,notify=37d:00000001 

 

 

What's the problem?

Thanks for help 

 

Contributor
Posts: 11
Registered: ‎08-28-2012
My Device: 9800
My Carrier: --

Re: ListView basics

Ok, now I feel like the dumbest person ever.

ListView is in Container, so there should obviously be

QObject* container =  root->findChild<QObject*>("container");
ListView* listview = container->findChild<ListView *>("listview");

 Sigh ...

 

Retired
Posts: 499
Registered: ‎05-07-2012
My Device: developer
My Carrier: developer

Re: ListView basics

Also, be sure to look at sample cascadescookbook, both the qml and cpp versions.

 

Stuart

Retired
Posts: 499
Registered: ‎05-07-2012
My Device: developer
My Carrier: developer

Re: ListView basics

You might be able to skip finding the container -- I believe findChild actually finds descendant.   (It might be faster your way, but it depends on the object being in the container)

 

Stuart