11-15-2012 12:13 PM
I have a Button in one of my ListItemComponents.
This button "consumes" the click event and emits clicked, but:
from the ListItemComponent i cannot access the outer qml page (or the classes registered from c++).
When i click on another part of the component the onTriggered of the ListView is called, but not when i click the button.
Is there a way to
- disable the "consume click" behavior of the button or
- access the qml or c++ class from the ListItemComponent
?
Solved! Go to Solution.
11-15-2012 12:48 PM
11-16-2012 04:58 AM
11-16-2012 11:24 AM - edited 11-16-2012 11:25 AM
Now I could have totally misunderstood the question but this is what I thought you were asking... The same would go for if you used a custom qml component as the contents of the listitemcomponent. You would do the accessing of the listview in the same way from inside that class, or from a gesturehandler defined inline in the listitemcomponent definition.
Container {
id: page1 //or whatever component with a context property set for your c++ class
ListView {
id: mylistview
ListItemComponents: [
ListItemComponent {
id: mycomp
Container {
id: containerContents
Label { text: "my list item" + ListItemData.title; }
gestureHandlers: [
TapHandler {
onTapped: containerContents.ListItem.view.doSomethingWithIte m(ListItemData);
}
]
}
}
]
function doSomethingWithItem(data) {
contextProp.callCPPMethod(data); //or do something else with it
}
}
}