PDA

View Full Version : set color in QTreeWidgetItem text



mattia
7th January 2008, 09:19
Hello, i have a QTreeWidgetItem * item and i'd like to set the color font in red and the font style in bold.
I made in this way


QFont font("" , 9 , QFont::Bold );
item->setFont( 0, font );

but i dont know how to set the font in red color, QTreeWidgetItem does not have palette() and setPalette() methods and i dont know another way to do it.
any hint?
thx

marcel
7th January 2008, 09:28
See QTreeWidgetItem::setForeground().

mattia
7th January 2008, 10:06
thx i did it in this way


QFont font("" , 9 , QFont::Bold );
QBrush b (Qt::red);
item->setForeground( 0 , b );
item->setFont( 0, font );