Facing an issue with Listview in Repeater
-
Hi Team,
I am trying to control the visibility of the listview control on every button click for respective data model.
But, I am getting below errors at "visible: buttonRepeater.model.expanded"
Unable to assign [undefined] to bool
Unable to assign [undefined] to bool
Unable to assign [undefined] to boolI am not sure what is wrong.
Can someone please help me in sorting out. Thank youimport QtQuick import QtQuick.Controls ApplicationWindow { visible: true width: 640 height: 480 ListModel { id: groupModel ListElement { name: "Model 1" expanded: false } ListElement { name: "Model 2" expanded: false } ListElement { name: "Model 3" expanded: false } } ListModel { id: model1Items ListElement { description: "Item 1.1" } ListElement { description: "Item 1.2" } ListElement { description: "Item 1.3" } } ListModel { id: model2Items ListElement { description: "Item 2.1" } ListElement { description: "Item 2.2" } ListElement { description: "Item 2.3" } } ListModel { id: model3Items ListElement { description: "Item 3.1" } ListElement { description: "Item 3.2" } ListElement { description: "Item 3.3" } } Column { anchors.fill: parent spacing: 10 Repeater { id: buttonRepeater model: groupModel delegate: Column { width: parent.width Button { text: model.name onClicked: { groupModel.setProperty(index, "expanded", !model.expanded) } } ListView { id: listView width: parent.width height: contentHeight visible: buttonRepeater.model.expanded model: buttonRepeater.model.name === "Model 1" ? model1Items : buttonRepeater.model.name === "Model 2" ? model2Items : model3Items delegate: Item { width: parent.width height: 30 Text { anchors.centerIn: parent text: model.description } } } } } } }
-
@Praveen-Illa said in Facing an issue with Listview in Repeater:
Hi Team,
I am trying to control the visibility of the listview control on every button click for respective data model.
But, I am getting below errors at "visible: buttonRepeater.model.expanded"
Unable to assign [undefined] to boolEdited to emphasize the problem:
Repeater { id: buttonRepeater model: groupModel delegate: Column { ListView { visible: buttonRepeater.model.expanded } } }
buttonRepeater.model.expanded
is attempting to access a property calledexpanded
in buttonRepeater'smodel
, not a role called expanded within a row of the model. Printing the values ofbuttonRepeater
andbuttonRepeater.model
should make this clear.