[Qt-interest] How to have dynamic pixmap in a QHeaderView item

David Boosalis david.boosalis at gmail.com
Thu Aug 19 20:40:28 CEST 2010


I want to be able to display a pixmap  in a item of a QTreeView's horizontal
header. I have created my own Horizontal Header Class, and have tried to add
my own Delegate to column 0 (the column where I want the pixmap to appear).
The trouble is I never see the paint() method for this Delegate.

At first I was setting the labels of the header with the model's method
setHorizontalHeaderLabels(QStringList columnNames).  I then went to the
trouble of creating a QStandardItem for each column and adding it to the
header with setHorizontalHeaderItem(col, headerItem).

After both methods I would create my delegate and add it to the header with:

MyHeaderDelegate *symbolDelegate = new MyHeaderDelegate(this);
horHeader->setItemDelegateForColumn(0,myHeaderDelegate);

I never see the debug message I have in the paint() method for
MyHeaderDelegate.

This is the approach I have used for things such as QTreeView and
QTableView, but QHeaderView, even though it  inherits from the same base
class  seems to be the bastard child.  Any ideas on how to be able to paint
pixmaps for a item in a horizontal header ? I want to be able to control if
the pixmap gets painted.  Is using a custom delegate the right way to go ?

Any advise greatly appreciated.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100819/5ea33bec/attachment.html 


More information about the Qt-interest-old mailing list