QTreeWidget gird lines
-
I am new to QT and I am trying to figure out how to add gridlines to the sections of a QTreeWidget. From what I can see, it looks like you have to override the paintEvent() or maybe the QStyledItemDelegate. I have also seen references to using style sheets. I was wondering if there is a recommended way.
Thanks in advance
Gary -
Hi,
I am unsure of the result you seek. Do you have an image of what you would like to obtain ?
-
@GaryT
If you are happy with the CSS solution at https://stackoverflow.com/questions/33911102/qtreeview-grid-line-colorQTreeView::item { border: 0.5px ; border-style: solid ; border-color: lightgray ;}
that is the simplest. (A
QTreeWidget
is aQTreeView
. Above should work for you, else tryQTableWidget
instead.) Read the comments there for a limitation.Otherwise @mrjj's code at https://forum.qt.io/topic/110101/how-to-create-grid-line-in-qtreewidget/6 shows a minimal delegate.