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. How to have a larger spacing for root items in a TreeView
Forum Updated to NodeBB v4.3 + New Features

How to have a larger spacing for root items in a TreeView

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 705 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.
  • hvoigtH Offline
    hvoigtH Offline
    hvoigt
    wrote on last edited by
    #1

    Hi,

    to emphasize the grouping of the root items in a TreeView I would like to adjust the spacing (or size) of just the root items.

    I tried doing it using the itemDelegate with a larger height based on styleData.depth like 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 itemDelegate does not have any influence on the height of rows.

    I found that in the rowDelegate I am able to adjust the height. But there is no styleData.depth available.

    Does anyone have an idea how I can achieve this with a TreeView?

    1 Reply Last reply
    0
    • hvoigtH Offline
      hvoigtH Offline
      hvoigt
      wrote on last edited by
      #2

      I just found out how to do this. There is a section.delegate in TreeView which is inherited from the ListView and 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.

      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