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

Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.

Posts: 20
Registered: ‎09-12-2012
My Device: Developer
My Carrier: Docomo

GroupDataModel was not taking objects


Here i have to display the objects in the output so i have defined a class for that and created a object for that  and i give that object to groupdatamodel but its not working check it once


here is the cpp file in that cpp i get the listview in main.qml and set the groupdatamodel


  GroupDataModel *m = new GroupDataModel(QStringList()<<"name");

//    		 QList<QObject *> lst;
//    		 lst << new Name("Test");

//    		QVariantMap *map;
//    		map->insert("name","RaviTeja");
//          m->insert(map);

//    	    lst->append(new Name("RaviTeja"));
//    	    m->insertList(lst);

    	    m->insert(new Name("RaviTEja"));

            ListView *list_view = root->findChild<ListView*>("listView");
            if(list_view) list_view->setDataModel(m);


here i have created an object of Name class which is a subclass of QObject and set into the model and the model is given to listview but in the output the Name class name variable data(RaviTeja) is not showing in listview





// Grid view with detail project template
import bb.cascades 1.0

NavigationPane {
    id: navigationPane
    firstPage: Page {
        id: pgMain
        content: Container {
            layout: DockLayout {
            ListView {
                id: listView
                // set object name to let listView to be discoverable from C++
                objectName: "listView"
                layout: GridListLayout {}
                listItemComponents: [
                    // define component which will represent list item GUI appearence
                    ListItemComponent {
                        type: "item"
                        // list item GUI appearence component is defined in external MyListItem.qml file
//                        MyListItem {}
                onTriggered: {
                    console.log("selected_index: " + indexPath)
                    var curr_item = dataModel.data(indexPath)
                    // show detail page for selected item
                horizontalAlignment: HorizontalAlignment.Center
                verticalAlignment: VerticalAlignment.Center
    attachedObjects: [
        ComponentDefinition {
            id: secondPageDefinition
            content: Page {
                property alias text: lblText.text
                property alias image: imgView.imageSource
                id: pgDetail
                paneProperties: NavigationPaneProperties {
                    backButton: ActionItem {
                        onTriggered: { navigationPane.pop(); }
                content: Container {
                    layout: StackLayout {
                    Label {
                        id: lblText
                        textStyle.base: SystemDefaults.TextStyles.TitleText
                        //textStyle.color: Color.Yellow
                        horizontalAlignment: HorizontalAlignment.Center
                    ImageView {
                        id: imgView
                        scalingMethod: ScalingMethod.AspectFit
                        layoutProperties: StackLayoutProperties {
                            spaceQuota: 1.0 // the image fills rest of the Page

                        verticalAlignment: VerticalAlignment.Center
                        horizontalAlignment: HorizontalAlignment.Center
    function setDetailItem(item) {
        // show detail page
        var page = secondPageDefinition.createObject();
        page.text = item.text
        page.image = item.image
    onCreationCompleted: {
        // this slot is called when declarative scene is created
        // write post creation initialization here
        console.log("NavigationPane - onCreationCompleted()")

        // enable layout to adapt to the device rotation
        // don't forget to enable screen rotation in bar-bescriptor.xml (Application->Orientation->Auto-orient)
        OrientationSupport.supportedDisplayOrientation = SupportedDisplayOrientation.All;


Posts: 526
Registered: ‎05-17-2009
My Device: 9900
My Carrier: ATT

Re: GroupDataModel was not taking objects

you need an itemType(data,index) function in the ListView qml to tell it to show one of your list view components of type "item"
Like all of my posts
Posts: 20
Registered: ‎09-12-2012
My Device: Developer
My Carrier: Docomo

Re: GroupDataModel was not taking objects

ya iam using like this ListItemData.name but not working  then how to get data in qml