在其委托中编辑列表视图的内容 Y



我试图改变checkB.onClicked内的customerList的内容函数。然而,我得到">ReferenceError: customerList is not defined";customerList.contentY=oldY;

customerList在该函数内的每一行都可以找到,它们工作得很好。但是,我不能编辑内容。

我试图编辑内容的原因是,当我做customerList.model.select();customerList得到更新,并定位在开始,但我不希望这样。我该如何解决这个问题?

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;
}
}
}

在它的委托中通过它的id访问listview可能会有问题。尝试使用ListView.view。model/contentY代替customerList.model/contentY

读到:附加属性

您尝试过没有customerList.model.select();行吗?不确定select()在这里应该做什么。ListModel没有select()方法。

我在基本的ListView中尝试过没有这一行,并且设置了contentty值。

最新更新