Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. child's visibility
Qt 6.11 is out! See what's new in the release blog

child's visibility

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 844 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    beh_zad
    wrote on last edited by
    #1

    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);
       }
    
    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved