Pregunta

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).

¿Fue útil?

Solución

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

QGroupBox{color: red;}

This way your QTreeWidget will ignore this stylesheet.

Otros consejos

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top