blackbubblegum
2nd January 2012, 13:32
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:
QVariant result = QStandardItemModel::headerData( section,
orientation,
role
);
if (result.toString().compare(QString("Special Column")) == 0)
{
QPixmap pixmap = QPixmap(5, 5);
pixmap.fill(Qt::red);
QIcon icon = QIcon(pixmap);
result.setValue(icon);
}
return result;
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
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:
QVariant result = QStandardItemModel::headerData( section,
orientation,
role
);
if (result.toString().compare(QString("Special Column")) == 0)
{
QPixmap pixmap = QPixmap(5, 5);
pixmap.fill(Qt::red);
QIcon icon = QIcon(pixmap);
result.setValue(icon);
}
return result;
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