PDA

View Full Version : QTableWidget QTableWidgetItem



TheKedge
6th September 2006, 15:37
Hello all,
sorry, I couldn't find exactly what I was looking for prevoius threads.
I want to change the color of a header of a column in a QTableWidget (to show that the column is 'active'). The column header is double clicked and I get a slot called in which I do this:


item = tableWidget->horizontalHeaderItem ( logicalIndex );
item->setBackgroundColor(ChannelEnabled);


There is no colour change to be seen. I can colour any other item in the table this way, but not those from the headers. What do I need to do?

Another thing...
the signal QTableWidget::itemDoubleClicked ( QTableWidgetItem * /*item*/ )
gets called on double click on any cell, except those in the headers.

thanks
Kev

jpn
6th September 2006, 15:50
There is no colour change to be seen. I can colour any other item in the table this way, but not those from the headers. What do I need to do?

You must either override
QHeaderView::paintSection()
or
use a custom style and implement:
QStyle::drawControl(QStyle::CE_Header)



Another thing...
the signal QTableWidget::itemDoubleClicked ( QTableWidgetItem * /*item*/ )
gets called on double click on any cell, except those in the headers.

QHeaderView::sectionDoubleClicked()


PS. Headers are accessible through QTableView::horizontalHeader() and QTableView::verticalHeader()

TheKedge
6th September 2006, 15:57
Yep,

QHeaderView::sectionDoubleClicked()
PS. Headers are accessible through QTableView::horizontalHeader() and QTableView::verticalHeader()
that're what I'm using at the moment.

I was a little irked that I could get the item, but that the QTableWidgetItem func didn't work.

I'll try your suggestions, thanks very much.

K

wysota
6th September 2006, 16:03
I was a little irked that I could get the item, but that the QTableWidgetItem func didn't work.
Headers are not items. They are not part of the data model data.