Hey there,

I have a QTreeView and reimplemented a QStandardItemModel. For some special columns I want to display icons instead of text. So I rewrote QStandardItemModel::headerData(...). I should return a QVariant created with an Icon at these columns. But the icon is not shown in the QTreeView. Instead the header is empty there.

My code looks like this:

Qt Code:
  1. QVariant result = QStandardItemModel::headerData( section,
  2. orientation,
  3. role
  4. );
  5.  
  6. if (result.toString().compare(QString("Special Column")) == 0)
  7. {
  8. QPixmap pixmap = QPixmap(5, 5);
  9. pixmap.fill(Qt::red);
  10. QIcon icon = QIcon(pixmap);
  11. result.setValue(icon);
  12. }
  13. return result;
To copy to clipboard, switch view to plain text mode 

I tried it with returning a lot of different Variants (icon, string, pixmap etc.) but nothing except QString works.

Did I mised something?
Do I need to reimplement paint from HeaderView?

Thanks and happy new year to all of you,
bbg