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: 692
Registered: ‎08-09-2010
My Device: Not Specified

GroupModel access into qml?

[ Edited ]

Hello,

 

    I define GroupModel into cpp and now this GroupModel i access into qml so how to possible?

 

   For exmple :-

 

     I define GroupModel into .cpp

 

    

GroupDataModel *model = new GroupDataModel(QStringList());
model->setGrouping(ItemGrouping::None);
listView = root->findChild<ListView *>("discussionsListView");
listView->setObjectName("");
listView->setDataModel(model);

     .qml i access GroupModel  but fetch error

 

    

ListView {
            objectName: "discussionsListView"
            onTriggered: {
                var chosenItem = categoryListModel.data(indexPath);
                console.log("value called"+chosenItem.text);
                var newPage = subCategoriesList.createObject();
                storeNavigationPane.push(newPage);
            }
        }

    So how to fetch groupModel into qml?

 

Thanks,

Umang.

Developer
Posts: 230
Registered: ‎01-12-2013
My Device: z30
My Carrier: Mobile Vikings

Re: GroupModel access into qml?

Is it a copy-paste error? Because the objectname in qml does not correspond to this line

 

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

 It should be

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

 Actually I don't get your question. The listview don't get populated or is it something else? Does the error occur at runtime or at startup?

 

______________________________________________________
BB10-OAuth: GitHub
Developer
Posts: 692
Registered: ‎08-09-2010
My Device: Not Specified

Re: GroupModel access into qml?

Hi Curahee,

 

        It's not issue.Just i provide you exmple.

  

        Orignal i need GroupdataModel value into qml they i not get.

 

        I declare GroupdataModel into Cpp file and now this data model value i need into qml which i define into my earlier post so how to get?

 

Thanks,

Umang.

Developer
Posts: 230
Registered: ‎01-12-2013
My Device: z30
My Carrier: Mobile Vikings

Re: GroupModel access into qml?

This is how I do it

 

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

GroupDataModel *model = new GroupDataModel(QStringList() << "location");
model->setGrouping(ItemGrouping::None);
model->setParent(this);

// insert data with model->insert(...);

listView->setDataModel(model);

 Probably, it's also possible to do it like this

 

ListView {
    id: delayList
    objectName: "delayList"
    leftPadding: 10
    rightPadding: 10
    dataModel: GroupDataModel { }
}

 

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

GroupDataModel *model = listView->dataModel();

// insert data with model->insert(...);

 Not sure about the last one though.

______________________________________________________
BB10-OAuth: GitHub