Search code examples
qtqtreewidgetqstyleditemdelegate

Set delegate for QTreeWidget header


I need to set delegate for QTreeWidget header or make it working with HTML tags using other ways.

I set a delegate for QTreeWidget items using

ui->tree->setItemDelegate(delegate);

and it works.

But setting a delegate to the header does not work :

ui->tree->header()->setItemDelegate(delegate);

Solution

  • It won't work and it's documented here http://qt-project.org/doc/qt-4.8/qheaderview.html#appearance

    Note: Each header renders the data for each section itself, and does not rely on a delegate. As a result, calling a header's setItemDelegate() function will have no effect.