Search code examples
qtqt4qtreeviewqtreewidgetqtstylesheets

How can i hide the border for qtreeview?


I want to hide the border of the QTreeWidget i´m customizing.

I want it to be the same when i select an item inside. But this special outline doesn´t work at all. I want it to be the same as the first image.

enter image description here

enter image description here

I use this piece of css code:

QTreeView  {
    show-decoration-selected: 0;
    background: transparent;
}

QTreeView::item:selected
{
    background-color: #00CDDF;
    font-weight: bold;
    outline: none;
}


QTreeView::branch:selected {
    background-color: #00CDDF;
    outline: none
}

Solution

  • Border and outline are different things. Look at this. Outline is separate property which is set to none by default. The visible line around your QTreeView is border property which has some default value.

    If you want to remove border, try to set border property like this.

    QTreeView {
         border: none;
    }
    

    For removing border on specific side,

    QTreeView {
         border: 1px solid;
         border-top: none;
    }
    

    For selected item you can use this selector, QTreeView::item, for active item(s) QTreeView::item:selected:active and for selected item(s) QTreeView::item:selected.