child's visibility
-
Hi everybody,
I created TreeModel and TreeView in QML, I used ListModel with ListElement to fill this model, but my problem is when my ListElement change my children visibility also change!! What I should to do when I want this visibility not change?Component { id: objRecursiveSubnodeDelegate Column { id: objRecursiveSubnodeColumn clip: true MouseArea { id: cbxcolumnAreaSubnode width: objRowSubnode.implicitWidth height: objRowSubnode.implicitHeight onClicked: { if(objRecursiveSubnodeColumn.children.length === 1) { cbxListView.currentIndex = index; if(columnTextSubnode.text !== "") { cbxtriggered = false; indexChanged(model.name,index); cbxTextBox.text = model.name; } } } Row { id: objRowSubnode Item { height: 1 width: model.level * 20 } Text { id: columnTextSubnode text: model.name color: "black" font.capitalization: Font.AllUppercase font { /*bold: true;*/ pixelSize: 14 } } } } } } Component { id: objRecursiveDelegate Column { id: objRecursiveColumn clip: true MouseArea { id: cbxcolumnArea width: objRow.implicitWidth height: objRow.implicitHeight function hideSubColumn() { for(var i = 1; i < parent.children.length - 1; ++i) { parent.children[i].visible = !parent.children[i].visible } } Component.onCompleted: { for(var i = 1; i < parent.children.length - 1; i++) { parent.children[i].visible = false; } } onClicked: { cbxcolumnArea.hideSubColumn(); } Row { id: objRow Item { height: 1 width: model.level * 20 + 5 } Image { id: upAndDown y: columnText.contentHeight / 3; width: 7; height: 7; source: objRecursiveColumn.children[1].visible ? "Down.png" : "Up.png"; } Item { height: 1 width: model.level * 20 + 5 } Text { id: columnText text: /*(objRecursiveColumn.children[1].visible ? qsTr("- ") : qsTr("+ ")) +*/ model.name color: "black" font { bold: true; pixelSize: 14 } } } } Repeater { model: subNode delegate: objRecursiveSubnodeDelegate } } } ListModel { id: cbxListModel; } ColumnLayout { width: cbxTextBox.width anchors.top: cbxTextBox.bottom; anchors.left: cbxTextBox.left; visible: cbxtriggered; ListView { id: cbxListView focus: true; spacing: listViewSpacing; model: cbxListModel delegate: objRecursiveDelegate clip: true; width: cbxRoot.width; // highlight: Rectangle { color: "lightsteelblue"; radius: 5; x:5 } height: (cbxRoot.height-cbxTextBox.height-2*edgeMargines - 2 * cbxRoot.border.width) < 0 ? 0.1 : (cbxRoot.height-cbxTextBox.height-2*edgeMargines - 2 * cbxRoot.border.width); }