在main.qml中,我在每个函数addItem()调用上动态更新listModel。在此,我将扮演两个角色。 buttonTypeRole和源。 OneText.qml文件具有“文本”字段。实际上,在将buttonTypeRole和source插入listModel之后,我想知道source是否被截断。
有什么办法做到这一点?
main.qml
RETURN STATEMENT
<LS.Chart_DIV>
<LS.Chart_SVG viewBox="0 0 12000 4000" ref={svgElement_ref}>
{lineItems}
{barItems}
</LS.Chart_SVG>
</LS.Chart_DIV>
listModel和ListView快照:
function additem()
{
listModel.insert(tlist.listModel.count , {"buttonTypeRole":"OneText.qml", "source":editText})
console.log("model-- "+tlist.listModel.get(sourceIndex).t)
}
buttonTypeRole:OneText.qml快照
Item
{
property alias listModel: listModel
ListModel
{
id:listModel
}
Rectangle
{
id:listHolder
border.color: "transparent"
border.width: 3
color:"transparent"
height:560
width:600
focus:true
ListView
{
//id:listview
x:5
y:5
spacing:10
width:700
height:listHolder.height - 20
id:list
boundsBehavior: ListView.StopAtBounds
model:listModel
delegate:listComponent
clip: true
snapMode:ListView.SnapToItem
}
}
Component
{
id:listComponent
Rectangle
{
//color:"grey"
width:obj.width
height:obj.height
border.color: "red"
Loader
{
id:itemDisplay
source:buttonTypeRole
}
}
}
}