Hi all,

i already spent some time googling & searching the forums, but somehow i failed to come up with a working solution. what i'm trying to do is, to simply give a QTreeWidgetItem the ability to display richtext.

However, i have some semi-working code i took from here: Link

Qt Code:
  1. class RichDelegate : public QItemDelegate
  2. {
  3. public:
  4.  
  5. void paint( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const
  6. {
  7. painter->save();
  8. doc.setHtml( index.data().toString() );
  9. QAbstractTextDocumentLayout::PaintContext context;
  10. doc.setPageSize( option.rect.size());
  11. painter->setClipRect( option.rect );
  12. painter->translate(option.rect.x(), option.rect.y());
  13. doc.documentLayout()->draw(painter, context);
  14. painter->restore();
  15. }
  16. };
To copy to clipboard, switch view to plain text mode 

I think it might have some problems still with sizes, since i dont reimplement the sizeHint() method (i read about that in some of the various other richtext-delegate threads).
this, however, is not my problem. the above code works for a QTableView, and the rows display richtext/html nicely. however, once i put

treeWidget->setItemDelegateForColumn(2, new RichDelegate());

my column in the treewidget wont display anything at all and will remain blank.
what am i doing wrong? i could switch to QTreeView/model in case thats the only solution, but i would prefer sticking to my QTreeWidget if possible.

any help appreciated