How to have a larger spacing for root items in a TreeView
-
Hi,
to emphasize the grouping of the root items in a
TreeViewI would like to adjust the spacing (or size) of just the root items.I tried doing it using the
itemDelegatewith a larger height based onstyleData.depthlike this:TreeView { anchors.fill: parent model: theModel itemDelegate: Rectangle { color: "#00000000" height: styleData.depth > 0 ? 20 : 40 Text { text: styleData.value } } TableViewColumn { role: "title" title: "Title" } TableViewColumn { role: "summary" title: "Summary" } }Unfortunately it seems that the
itemDelegatedoes not have any influence on the height of rows.I found that in the
rowDelegateI am able to adjust the height. But there is nostyleData.depthavailable.Does anyone have an idea how I can achieve this with a
TreeView? -
I just found out how to do this. There is a
section.delegateinTreeViewwhich is inherited from theListViewand can be used the same. Through this one can add an extra property to group the items in sections. When you only do this to the root items you can use this to add spaces to the root items.