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. QT quick TreeView and TreeViewStyle
Forum Updated to NodeBB v4.3 + New Features

QT quick TreeView and TreeViewStyle

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 200 Views
  • 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.
  • Pieter CardoenP Offline
    Pieter CardoenP Offline
    Pieter Cardoen
    wrote on last edited by
    #1

    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

    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