Background Colors in QTreeWidget Items / January 2011 / Qt 4.6.3 Excerpts from QtUtils/MassBalSummaryDlg.hpp and .cpp (before the QTreeWidget was replaced with a QTreeView). See Image: http://cadswes2.colorado.edu/~philw/2011/MassBalSum/2012-01-02/images/dlg1.gif http://cadswes2.colorado.edu/~philw/2011/MassBalSum/2012-01-02/images/dlg2.gif class MassBalSummaryPanel::TreeItem : public QTreeWidgetItem { ... ... ... private: void setBgColor(); ... ... ... }; static const QBrush ItemBg_BalGrp (QColor (0xFF, 0xcc, 0xFF)); static const QBrush ItemBg_Balance (QColor (0xcc, 0xFF, 0xFF)); static const QBrush ItemBg_SlotGrp (QColor (0xFF, 0xFF, 0xcc)); static const QBrush ItemBg_Slot (QColor (0xcc, 0xFF, 0xcc)); ... ... ... void MassBalSummaryPanel::TreeItem::setBgColor() { QBrush bgBrush = background (0); switch (_level) { case 1: bgBrush = ItemBg_BalGrp; break; case 2: bgBrush = ItemBg_Balance; break; case 3: bgBrush = ItemBg_SlotGrp; break; case 4: bgBrush = ItemBg_Slot; break; } const int colCnt = columnCount(); for (int col = 0; col < colCnt; ++col) { setBackground (col, bgBrush); } } ---