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: 528
Registered: ‎10-06-2009
My Device: 9800,BB Dev Alpha,z10 limited edition
My Carrier: Vodafone

Not able to load data in listview

Hi,

 

I am trying to insert data into groupdatamodel . The QVariantlist is not empty but its giving error when I am calling 

arrayModel->insertList(sqlData);

 

Can someone help?

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

Re: Not able to load data in listview

Can you please post the code and error message?

Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 528
Registered: ‎10-06-2009
My Device: 9800,BB Dev Alpha,z10 limited edition
My Carrier: Vodafone

Re: Not able to load data in listview

arrayModel = navigationPane->findChild<GroupDataModel*>("scoreModel");

 arrayModel->insertList(scoreList);

 

in qml

 

ListView{

                        id: scoreList

                                       objectName: "scoreList"

                                       

                                       layout: StackListLayout {

                                          // headerMode: ListHeaderMode.Sticky

                                       }

                        dataModel: scoreModel

                        

                          listItemComponents: [

                                            ListItemComponent {

                                                type: "item"

                                                StandardListItem {

                                                    imageSpaceReserved: false

                                                    title: {

                                                        // Some entries only have a last name (we enforce last name always being added)

                                                        if (ListItemData.firstname == undefined) {

                                                            ListItemData.lastname

                                                        } else {

                                                            ListItemData.firstname + " " + ListItemData.lastname;

                                                        }

                                                    }

                                                }

                                            }, ListItemComponent {

                                                                    type: "header"

                                                                    Header {

                                                                        title: ListItemData

                                                                    }

                                                                }

                                            ]

                                        attachedObjects: [

                                                          // A GroupDataModel is used for presenting the SQL data. All set up is done here

                                                          // except for the actual population of the model, which is done in C++.

                                                          GroupDataModel {

                                                              id: scoreModel

                                                              objectName: "scoreModel"

                                                              grouping: ItemGrouping.ByFirstChar

                                                              //sortingKeys: ["lastname", "firstname"]

                                                              

                                  }]

                       }         

        

 

 

The error is 

 

Process 14946500 (Etyoms) terminated SIGSEGV code=1 fltno=11 ip=79349a74(/base/usr/lib/libbbcascades.so.1@_ZN2bb8cascades14GroupDataModel6insertERK4QMapI7QString8QVariantE+0xb) mapaddr=00149a74. ref=00000008

 

 

The listview is not in mail.qml ,its in other page which will open when clicking on button from main.qml

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

Re: Not able to load data in listview

Try adding some logging:

qDebug() << "scoreList=" << scoreList << "\n";

arrayModel = navigationPane->findChild<GroupDataModel*>("scoreModel");

qDebug() << "arrayModel=" << arrayModel << "\n";

arrayModel->insertList(scoreList);


Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 528
Registered: ‎10-06-2009
My Device: 9800,BB Dev Alpha,z10 limited edition
My Carrier: Vodafone

Re: Not able to load data in listview

qDebug()<<"scorelist size"<<scoreList.size();

                       arrayModel = navigationPane->findChild<GroupDataModel*>("scoreModel");

                       qDebug() << "arraymodel=" << arrayModel << "\n";

                       //arrayModel=new GroupModel();

                       qDebug("after array");

                       arrayModel->insertList(scoreList);

                       qDebug("after insert");

 

 

log:

Debug: scorelist size 1 

Debug: scoreList= QObject(0x0)  

 

Debug: after array

 

Process 15249604 (Etyoms) terminated SIGSEGV code=1 fltno=11 ip=79249a74(/base/usr/lib/libbbcascades.so.1@_ZN2bb8cascades14GroupDataModel6insertERK4QMapI7QString8QVariantE+0xb) mapaddr=00149a74. ref=00000008

 

so the process terminates when calling insertlist

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

Re: Not able to load data in listview

[ Edited ]

 qDebug() << "arraymodel=" << arrayModel << "\n";

 

I don't see "arraymodel=" output in logs.


Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 528
Registered: ‎10-06-2009
My Device: 9800,BB Dev Alpha,z10 limited edition
My Carrier: Vodafone

Re: Not able to load data in listview

Sorry actually scorelist is arraymodel ,I write log wrongly

 

Debug: scorelist size 1 

Debug: arraymodel= QObject(0x0)  

 

Debug: after array

 

Process 15249604 (Etyoms) terminated SIGSEGV code=1 fltno=11 ip=79249a74(/base/usr/lib/libbbcascades.so.1@_ZN2bb8cascades14GroupDataModel6insertERK4QMapI7QString8QVariantE+0xb) mapaddr=00149a74. ref=00000008

 

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

Re: Not able to load data in listview

[ Edited ]

Ok, thanks. It seems arrayModel wasn't found by findChild.
In logs we see that it's NULL, that's why it crashes.

If it was initialized properly you would see something like:
bb::cascades::ArrayDataModel(0x817c7e8)

when it's NULL it's printed as
QObject(0x0)

 

In QML I see it's attached to ListView, not NavigationPane.

You'll have to obtain the pointer to listView to get the model or attach the model to navigationPane.

 


Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 528
Registered: ‎10-06-2009
My Device: 9800,BB Dev Alpha,z10 limited edition
My Carrier: Vodafone

Re: Not able to load data in listview

Yes,I have included that line when I posted code that the listview is not in the main qml file,it opens when clicking on button on main qml.

 

So navigationpane is in main qml and other qml where listview is ,is not direct child. How can I load data then to the listview?

Rujuta Trivedi