Вопрос

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