I am trying to change the contentY of customerList inside the checkB.onClicked function. However I get the "ReferenceError: customerList is not defined" error on the customerList.contentY=oldY; line and that line only.
customerList is found in every other line inside that function and they work fine. However, I cannot edit the contentY.
The reason why I am trying to edit the contentY is that when I do customerList.model.select(); the customerList gets updated and gets positioned at the start but I do not want that. How can I fix this?
ListView{
id:customerList
Layout.preferredHeight: 452
Layout.preferredWidth: parent.width
Layout.fillHeight: true
clip: true
spacing:0
model: myListModel
delegate: CustomerListDelegate{
id:listDelegate
checkB.checked: model.checked==="true" ? true : false
isCheckAvailable: true
width: customerList.width
height: 64
customerProfileImageSource: imageSource
customerName: name
customerDate: date
customerTotalPd: totalPd
customerPanto: panto
customerVertex: vertex
customerLensType: lensType
itemIndex: index
checkB.onClicked: {
var oldY=customerList.contentY;
if(checkB.checked==true)
myListModel.checkCustomer(index);
else
myListModel.uncheckCustomer(index);
customerList.model.select();
customerList.contentY=oldY;
}
}
}
CodePudding user response:
there may be an issue with accessing the listview by it's id within it's delegate. try to instead use ListView.view.model/contentY instead of customerList.model/contentY
Read about: Attached properties
CodePudding user response:
Have you tried it without the customerList.model.select();
line? Not sure, what the select() should do here. ListModel does not have a select() method.
I have tried it without this line in a basic ListView and the setting of the contentY value works.