문제

How to change the color of every text in QTreeWidget (item text, name of column)?

In fact, I have a QTreeWidget inside a GroupBox and when I have modified the styleSheet of my GroupBox, this was inherited in the QTreeWidget. So, I have modified the styleSheet in the QTreeWidget with color: rgb(0, 0, 0);, but when I execute the application, the color is the same as the GroupBox and not the stylesheet of QTreeWidget (whereas it is modified in the designer).

도움이 되었습니까?

해결책

When you set a stylesheet for your QGroupBox do it like this:

QGroupBox{color: red;}

This way your QTreeWidget will ignore this stylesheet.

다른 팁

YOu could try using QTreeWIdgetItem:SetForeground

or to set the background you could use

  item->setBackground(column, QBrush());

qsetheaders sets the headers for the columns in a QtreeWidget

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top