سؤال

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