Search code examples
qtqtreeviewqtstylesheets

qss: how to get QTreeView bottom border to appear under the branch subcontrol


I have a QTreeView in my application, where I need to draw borders around every cell. If I set my style like this:

QTreeView::item
{
    border-right: 1px solid #6d6d6d;
    border-bottom: 1px solid #6d6d6d;
    border-left: none;
    border-top: none;
}

The border does not appear under the branch sub-control: enter image description here

If I set the border on the branch area:

QTreeView::branch
{
    border-bottom: 1px solid #6d6d6d;
}

Then the branch image (triangle) disappears. enter image description here

Ideally, I would like to set the border from the style.

Thanks!


Solution

  • Found it: image and background-image work for branches and can be combined with border-image:

    QTreeView::branch
    {
        border-bottom: 1px solid #6d6d6d;
    }
    QTreeView::branch:closed:has-children 
    {
        image: url(:/img/collapsed);
    }
    QTreeView::branch:open
    {
        image: url(:/img/expanded);
    }