Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QT quick TreeView and TreeViewStyle



  • I am trying to create a tree view using QT quick controls 1.4. I currently have this result:
    qttreeview.png

    I however have problems getting the layout in a decent way. I am using TreeViewStyle with a custom branch delegate which should include an icon. On the image, I used just a green circle to indicate the icon position. I note that the branch delegate is shifted to the left side and partially hidden.

    I could fix this by increasing the indentation but that's not what I like. Is there any possible way to specify an offset for the indentation?

    style: TreeViewStyle {
    alternateBackgroundColor : "lightgray"
    branchDelegate: Rectangle {
    width: treeview.rowHeight * 2 + treeview.indent;
    height: treeview.rowHeight
    color: "transparent"

        CustomBranchDelegate{
            id: bd
            width: parent.height
            height: parent.height
            anchors.right: icon.left
            anchors.top: parent.top
            expanded: styleData.isExpanded
            hasChildren: styleData.hasChildren
            iconheight: 40
            color: "transparent"
        }
        Rectangle{
            id: icon
            anchors.right : parent.right
            anchors.top: parent.top
            radius: height / 2
            width: parent.height
            height: parent.height
            color: "green"
        }
    }
    rowDelegate : Rectangle{
        anchors {left: parent.left; right: parent.right; }
        color: styleData.alternate  ? "transparent" : "lightgray"
        height: treeview.rowHeight
    }
    
    indentation: treeview.indent
    

    }

    Thanks
    Pieter


Log in to reply