PDA

View Full Version : 3 Different Color for in QTablewidgetItem



jnana
21st March 2006, 06:04
Hi All,

I want to add backgound of three different color to QTableWidgetItem. Is there any way to achieve this? Waiting for ur reply.


Thanks
Jnana

wysota
21st March 2006, 09:58
Use setData with Qt::BackgroundColorRole role.

jnana
21st March 2006, 10:44
Hi wysota,

Thanks for reply. But, I was not able to follow it.

setData () takes two argument, one Qt::BackgroundRole, another a QVariant object. I don't know what should be the latter object. Is it possible by adding QBrush with QGrident as second argument will change the background color to gradient type color? If I am wrong can explain what u want to convey to me.

Thanks
Jnana

wysota
21st March 2006, 11:38
setData () takes two argument, one Qt::BackgroundRole, another a QVariant object. I don't know what should be the latter object.
The value you want to set.


Is it possible by adding QBrush with QGrident as second argument will change the background color to gradient type color?
It is possible but as far as I remember the default delegate (QItemDelegate) doesn't handle gradients, so it'll probably not work. It's safest to put some QColor (you can add a pattern too) there. Play with it.