我想弄清楚如何能夠點擊黑莓列表中的項目。我使用的是QML,C++,QT和Blackberry 10 Cascades。我已經實現了列表視圖,然後我嘗試着讓它可以通過查看這個Twitter時間軸示例來點擊列表上的一個項目(順便說一句 - 我無法運行該示例)。如何響應點擊qml列表中的列表項,在c + + qt中,在黑莓10瀑布
我在做什麼是行不通的。當我調用listView _-> setListItemManager(new CustomerListItemManager(customerListContainer_))時,它會導致列表視圖爲空(在添加代碼之前,列表視圖顯示出來)。
所以基本上如何獲得單擊列表上的項目並使其響應工作的能力。
反正 - 這裏是我迄今爲止嘗試過相關代碼:
Container {
id: customersListContainer
objectName: "customersListContainer"
ListView {
id: customersList
objectName: "customersList"
listItemComponents: [
ListItemComponent {
type: "item"
Container {
HeaderListItem {
title: ListItemData.firstName + " " + ListItemData.lastName
}
StandardListItem {
title: ListItemData.officePhone + "\t" + ListItemData.cellPhone
description: ListItemData.email
}
]
}
}
CustomerListItemManager.cpp:
CustomerListItemManager::CustomerListItemManager() {}
CustomerListItemManager::~CustomerListItemManager() {}
VisualNode *CustomerListItemManager::createItem(ListView *list, const QString &type)
{
//the CustomerList::getInstance()->customerListContainer returns the customersListContainer (see the qml code above)
//
return new CustomerItem(CustomerList::getInstance()->customerListContainer());
}
void CustomerListItemManager::updateItem(ListView *list, VisualNode *control, const QString &type, const QVariantList &indexPath, const QVariant &data)
{
QObject* obj = qvariant_cast<QObject *>(data);
CustomerData* customer = qobject_cast<CustomerData *>(obj);
}
CustomerItem.cpp:
CustomerItem::CustomerItem(Container *parent) : CustomControl(parent) {}
CustomerItem::~CustomerItem() {}
void CustomerItem::updateItem(const QString text, QDateTime date) {}
void CustomerItem::select(bool select) {
// Is this where you handle the response to clicking on an item on the list???
//
if (select) qDebug() << "item selected";
else;
}
void CustomerItem::reset(bool selected, bool activated) {
select(selected);
}
void CustomerItem::activate(bool activate) { Q_UNUSED(activate); }
填充一個在另一個文件中列出:
for (int i = 0; i < customers->length(); ++i) {
groupDataModel_.insert(customers->at(i)
}
listView_->setDataModel(&groupDataModel_);
//the customerListContainer_ is the customersListContainer (see the qml code above)
//
listView_->setListItemManager(new ListItemManager(customerListContainer_);
onTriggered不存在。 – Michael