Re: solution Re: QT4: How to set colours to the HeaderItem in a QTableWi
Re: solution Re: QT4: How to set colours to the HeaderItem in a QTableWidget
Sat, 24 Sep 2005 20:52:20 +0200
after some research I found the solution for coloring Highlight color
for each Widget in the QTableWidget.
1. I subclass the QItemDelegate and reimplement the paint method so that
I can use a selfdefined PaletteRole (a Role above the UserRole with
number 32) which pass a QPalette to the widget data.
2. use setData method for passing the QPalette data to the
3. set the subclassed QItemDelegate to the QTableWidget instance and
enjoy the new QPalette in action :-)
Unfortunately the QPalette data are ignored completely in the
Tableheader. So I have to use my workaround again.
BTW: If you want to draw a text to the table header it is much more
faster to set a new item which includes the header text than using the
setHorizontalHeaderLabels method. I tested this with tables with more
than 5000 rows.
Am Freitag, den 23.09.2005, 08:13 +0200 schrieb Frank Neuber:
> Hi Trolls,
> another thing I need is setting QPalette::Highlight color for the
> QTableWidgetItem to show the selection in the QTableWidget correct.
> e.g if I select a row then the selected colord (red) Items should be
> visable (darkRed) and the other items with the default selection color.
> In QT3 I did this by subclassing the table item and defining a new color
> group. In QT4 it is not possible by doing ti->setData(Qt::WA_SetPalette,
> It does compile and des not produce runtime errors but it has also no
> Please let me know how can I do this.
> > > Perhaps the QPalette::Text role is what you should be setting...
> > I added the p.setColor(QPalette::Text, Qt::yellow); just for testing
> > without success.
> > As I sad above, setting the QPalette has no effect neither in the table
> > nor in the table header.
> > > There is also some color control available to tables with RichText tags...
> > What do you mean with tags? I can insert items to the table and the
> > table header. The question is how can I change the behavior of the item
> > so that it is colored in the header.
> > Maybe that is not the only one way to color the table header. Please let
> > me know how can I do this.
> I found a workaround for me. I disabled the vertical header and use the
> first col as the table header .... really ugly ....
> Kind regards,
> To unsubscribe - send "unsubscribe" in the body to
> List archive and information: http://lists.trolltech.com/qt-interest/
To unsubscribe - send "unsubscribe" in the body to
List archive and information: http://lists.trolltech.com/qt-interest/