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