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
Highlighted
New Contributor
Posts: 2
Registered: ‎02-28-2013
My Device: DEV-ALPHA B
My Carrier: None
Accepted Solution

Error when calling insertList from GroupDataModel

Hi.

I have a program based on the “Quotes” example.

Right now I’m trying to load data from a .db file and insert it into my ListView.

 

bool Class::loadQMLScene() {

	QmlDocument *qmlDocument = QmlDocument::create("asset:///main.qml");

	if (!qmlDocument->hasErrors()) {
		qmlDocument->setContextProperty("_myClass", this);

		NavigationPane* navigationPane = qmlDocument->createRootObject<NavigationPane>();

		if (navigationPane) {

			QVariantList sqlData = closerDbHelper->loadDataBase("cards.db", "cards");

			qDebug() << sqlData;

			if (!sqlData.isEmpty()) {

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

				cardsModel->insertList(sqlData);

				cardsListView = navigationPane->findChild<ListView*>("cardsReceivedList");
			}

			Application::instance()->setScene(navigationPane);
			return true;
		}
	}

	return false;
}

 

The code

 

qDebug() << sqlData;

 shows my data on the device log.

INFO (QVariant(QVariantMap, QMap(("name", QVariant(QString, "Lucas") ) ) ) )  

How ever, the code

cardsModel->insertList(sqlData);

 generates an error: No source available for "0xb85bd8bb"

 

 

This is my QML code:

 

NavigationPane {
    id: nav
    property variant contentView
    property bool addShown: false
    Page {
        id: cardsReceivedListPage
        Container {
            ListView {
                id: cardsReceivedList
                objectName: "cardsReceivedList"
                layout: StackListLayout {
                    headerMode: ListHeaderMode.Sticky
                }                
                dataModel: cardsModel
                listItemComponents: [
                    ListItemComponent {
                        type: "item"
                        StandardListItem {
                            imageSpaceReserved: false
                            title: {
                                ListItemData.name;
                            }
                        }
                    }
                    ,
                    ListItemComponent {
                        type: "header"
                        Header {
                            title: ListItemData
                        }
                    }
                ]
                onTriggered: {
                    select(indexPath);
                    var page = cardPageDefinition.createObject();
                    nav.push(page);
                }
                onSelectionChanged: {
                    if (selected) {
                        var chosenItem = dataModel.data(indexPath);
                        _contentView = chosenItem.name;
                    }
                }
                attachedObjects: [
                    GroupDataModel {
                        id: cardsModel
                        grouping: ItemGrouping.ByFirstChar
                        sortingKeys: [
                            "name"
                        ]

                        onItemAdded: {
                            if (addShown) {
                                if (nav.top == cardsReceivedListPage) {
                                    cardsReceivedList.clearSelection();
                                    cardsReceivedList.select(indexPath);
                                    cardsReceivedList.scrollToItem(indexPath, ScrollAnimation.Default);
                                    var page = quotePageDefinition.createObject();
                                    nav.push(page);
                                }
                            }
                        }
                        onItemRemoved: {
                            var lastIndexPath = last();
                            if (lastIndexPath[0] == undefined) {
                                if (nav.top != cardsReceivedListPage) {
                                    nav.popAndDelete();
                                }
                            }
                        }
                        onItemUpdated: {
                            var chosenItem = data(indexPath);
                            _contentView = chosenItem;
                        }
                    }
                ] // End of AttachedObjects
            } // End of ListView
        } // End of Container

        actions: [
            ActionItem {
                title: "Create New Card"
                ActionBar.placement: ActionBarPlacement.OnBar
                onTriggered: {
                    createCard.open();
                    nav.addShown = true;
                }
            }
        ] // end of attachedObjects
        attachedObjects: [
            Sheet {
                id: createCard
                CardCreator {
                    id: cardPage
                    CardCreatorClose: {
                        createCard.close();
                    }
                }
                onClosed: {
                         createCard.close();;
                }
            },
            ComponentDefinition {
                id: cardPageDefinition
                source: "CardPage.qml"
            }
        ] // end of attachedObjects
    } // End of Page

 

The cardsModel is declared on the hpp file.

Any ideias on this problem?

 

 

 

 

 

 



New Contributor
Posts: 2
Registered: ‎02-28-2013
My Device: DEV-ALPHA B
My Carrier: None

Re: Error when calling insertList from GroupDataModel

I found the error.

It happens that I delete the property objectName: "cardsModel" from the GroupDataModel on the QML because the IDE shows an error "property unknown". However I ignored the error and it works fine.