I set a context object in the main method of my app:
// Load the UI description from main.qml
QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(&app);
// Make the Corporate object available to the UI as context property
qml->setContextProperty("_corporate", new Corporate(&app));
But I cannot access the _corporate object from within the onTouch
method, while at the same time the _corporate object is properly accessed in the onTriggered method. Here's the code:
ListView {
dataModel: _corporate.model
id: myListView
listItemComponents: [
ListItemComponent {
id: groupItemComponent
type: "groupItem"
StandardListItem {
id: groupListItem
title: qsTr ("%1").arg(ListItemData.firstRow)
description: ListItemData.secondRow
onTouch: {
_corporate.currentView = 3
}
}
}
]
onTriggered: {
_corporate.currentView = 3
}
}
What am I doing wrong?
_corporate cannot be accessed from within a ListItemComponent.
You have to give the access in another way: