View Full Version : how to use html tags(rich text) in QTableWidgetHeaderItem

13th December 2010, 11:20
I was to use sub script notation in QTableWidget horizonatal header item. ie something like IBASE and the word "BASE" should appears in subscript notation. I try to do:

ui.tableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem("I<sub>BASE</sub>"));

But this doesn't help as QTableWidgetItem doesn't support html tags like <sub> etc

After searching on I came to know that this can be done through QItemDelegate but don't have any code example to showing how to do so. Please help with some code example...

Note : I can get the sub script notation to work on QTableWidget cells since I use QTableWidget::setCellWidget() and put a QLabel(which supports html tags) as the cell widget instead of QTableWidgetItem . But I can't do so for horizonatal and vertical headers since setCellWidget() isn't designed to work for headers.

Please help....